Sha256: 0c7d8c2fce39470ae004525e5087b4ce9ad6537256e16a42c435809e543b6626

Contents?: true

Size: 688 Bytes

Versions: 3

Compression:

Stored size: 688 Bytes

Contents

# encoding: utf-8
module Sunrise
  module Models
    module Role
      def self.included(base)
        base.send :include, InstanceMethods
        base.send :extend,  ClassMethods
      end
      
      module ClassMethods
        def self.extended(base)
          base.class_eval do
            belongs_to :user
        
            enumerated_attribute :role_type, :id_attribute => :role_type
            attr_accessible :role_type
            
            scope :with_type, lambda { |role_type| where(:role_type => role_type) } 
          end
        end
      end
      
      module InstanceMethods
        def to_sym
          role_type.code
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sunrise-core-0.2.2 lib/sunrise/models/role.rb
sunrise-core-0.2.1 lib/sunrise/models/role.rb
sunrise-core-0.2.0 lib/sunrise/models/role.rb