Module: Cream::View::Role
- Defined in:
- lib/cream/view/role_area.rb,
lib/cream/configure/after_init/role_config.rb
Class Method Summary collapse
Instance Method Summary collapse
- #area(options = nil, &block) ⇒ Object
-
#area_for_roles(*user_roles, &block) ⇒ Object
(also: #area_for_role)
for users WITH the given roles create a div area with optional class given in options hash and render block within this div.
-
#area_not_for_roles(*user_roles, &block) ⇒ Object
(also: #area_not_for_role)
for users WITHOUT the given roles create a div area with optional class given in options hash and render block within this div.
Class Method Details
Instance Method Details
#area(options = nil, &block) ⇒ Object
33 34 35 36 |
# File 'lib/cream/view/role_area.rb', line 33 def area(=nil, &block) content = yield #with_output_buffer(&block) content_tag :div, content, end |
#area_for_roles(*user_roles, &block) ⇒ Object Also known as: area_for_role
for users WITH the given roles create a div area with optional class given in options hash and render block within this div
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/cream/view/role_area.rb', line 8 def area_for_roles(*user_roles, &block) = last_option(user_roles) return area(&block) if user_roles.empty? not_for_roles(user_roles, &block) if user_roles.first == false for_roles user_roles do area(, &block) end end |
#area_not_for_roles(*user_roles, &block) ⇒ Object Also known as: area_not_for_role
for users WITHOUT the given roles create a div area with optional class given in options hash and render block within this div
24 25 26 27 28 29 30 |
# File 'lib/cream/view/role_area.rb', line 24 def area_not_for_roles(*user_roles, &block) = last_option(user_roles) not_for_roles user_roles do clazz = [:class] || 'special' area(:class => clazz, &block) end end |