Skip to content

Commit

Permalink
create link helper
Browse files Browse the repository at this point in the history
  • Loading branch information
dvanderbeek committed May 14, 2018
1 parent cdf2907 commit b52cb4c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
3 changes: 3 additions & 0 deletions lib/segment/scopes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
require "segment/scopes/version"
require "segment/scopes/scope"
require "segment/scopes/controller_extension"
require "segment/scopes/link_helper"

module Segment
module Scopes
Expand All @@ -15,3 +16,5 @@ def self.configure
end
end
end

ActionView::Base.send :include, Segment::Scopes::LinkHelper
7 changes: 0 additions & 7 deletions lib/segment/scopes/controller_extension.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
module Segment
module Scopes
module ControllerExtension
def scope_link(scope, current_scope)
link_to scope.name.titleize,
params.to_unsafe_h.merge(scope: scope.name),
class: "btn btn-sm btn-#{scope == current_scope ? 'primary' : 'light'}"
end
helper_method :scope_link

private

def segment(view, klass)
Expand Down
11 changes: 11 additions & 0 deletions lib/segment/scopes/link_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module Segment
module Scopes
module LinkHelper
def scope_link(scope, current_scope)
link_to scope.name.titleize,
params.to_unsafe_h.merge(scope: scope.name),
class: "btn btn-sm btn-#{scope == current_scope ? 'primary' : 'light'}"
end
end
end
end

0 comments on commit b52cb4c

Please sign in to comment.