Module: Rabarber::Helpers

Includes:
Core::Roleable
Defined in:
lib/rabarber/helpers/helpers.rb

Instance Method Summary collapse

Methods included from Core::Roleable

#roleable, #roleable_roles

Instance Method Details

#hidden_from(*roles, context: nil, &block) ⇒ Object



13
14
15
16
17
# File 'lib/rabarber/helpers/helpers.rb', line 13

def hidden_from(*roles, context: nil, &block)
  return if roleable_roles(context: Rabarber::Input::Context.new(context).process).intersection(Rabarber::Input::Roles.new(roles).process).any?

  capture(&block)
end

#visible_to(*roles, context: nil, &block) ⇒ Object



7
8
9
10
11
# File 'lib/rabarber/helpers/helpers.rb', line 7

def visible_to(*roles, context: nil, &block)
  return if roleable_roles(context: Rabarber::Input::Context.new(context).process).intersection(Rabarber::Input::Roles.new(roles).process).none?

  capture(&block)
end