Sha256: b4cbbf939013b63501ff252e68e901731b360d66d6fd40e4f424a0d69583af1e

Contents?: true

Size: 1.12 KB

Versions: 31

Compression:

Stored size: 1.12 KB

Contents

require 'sugar-high/arguments'

module Cream::View
  module Role
    # for users WITH the given roles create a div area
    # with optional class given in options hash and render block
    # within this div  
    def area_for_roles(*user_roles, &block)
      options = 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(options, &block)
      end
    end   
    alias_method :area_for_role, :area_for_roles

    # for users WITHOUT the given roles create a div area
    # with optional class given in options hash and render block
    # within this div  
    def area_not_for_roles(*user_roles, &block)
      options = last_option(user_roles)
      not_for_roles user_roles do             
        clazz = options[:class] || 'special'
        area(:class => clazz, &block)
      end
    end  
    alias_method :area_not_for_role, :area_not_for_roles
    
    def area(options=nil, &block)
      content = yield #with_output_buffer(&block)
      content_tag :div, content, options
    end    
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
cream-0.9.2 lib/cream/view/role_area.rb
cream-0.9.1 lib/cream/view/role_area.rb
cream-0.9.0 lib/cream/view/role_area.rb
cream-0.8.9.3 lib/cream/view/role_area.rb
cream-0.8.9.2 lib/cream/view/role_area.rb
cream-0.8.9.1 lib/cream/view/role_area.rb
cream-0.8.9 lib/cream/view/role_area.rb
cream-0.8.8 lib/cream/view/role_area.rb
cream-0.8.7 lib/cream/view/role_area.rb
cream-0.8.6 lib/cream/view/role_area.rb
cream-0.8.5 lib/cream/view/role_area.rb
cream-0.8.4 lib/cream/view/role_area.rb
cream-0.8.3 lib/cream/view/role_area.rb
cream-0.8.2 lib/cream/view/role_area.rb
cream-0.8.1 lib/cream/view/role_area.rb
cream-0.8.0 lib/cream/view/role_area.rb
cream-0.7.10 lib/cream/view/role_area.rb
cream-0.7.8 lib/cream/view/role_area.rb
cream-0.7.7 lib/cream/view/role_area.rb
cream-0.7.6 lib/cream/view/role_area.rb