Sha256: 8112d9232047cd08544fae858ce29eaa05b60be11d699acb6b5c06caa9303394

Contents?: true

Size: 676 Bytes

Versions: 7

Compression:

Stored size: 676 Bytes

Contents

module Roles::ActiveRecord
  module Strategy
    module Shared
      def set_role role
        vr = new_role(role)
        # self.send("#{role_attribute}=", vr)
        update_attributes(role_attribute => vr)
      end
      alias_method :set_roles, :set_role

      def get_role
        r = self.send(role_attribute)
        # respond_to?(:present_role) ? present_role(r) : r
      end

      def get_roles
        r = self.send(role_attribute)
      end

      def select_valid_roles *roles
        roles.flat_uniq.select{|role| valid_role? role }
        has_role_class? ? role_class.find_roles(roles).to_a.flat_uniq : roles.flat_uniq
      end           
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
roles_active_record-0.4.0 lib/roles_active_record/strategy/shared.rb
roles_active_record-0.3.6 lib/roles_active_record/strategy/shared.rb
roles_active_record-0.3.5 lib/roles_active_record/strategy/shared.rb
roles_active_record-0.3.4 lib/roles_active_record/strategy/shared.rb
roles_active_record-0.3.3 lib/roles_active_record/strategy/shared.rb
roles_active_record-0.3.2 lib/roles_active_record/strategy/shared.rb
roles_active_record-0.3.1 lib/roles_active_record/strategy/shared.rb