Sha256: 924b5403cb44b891e5e39a3ada381a53b7d559f1cd54e66d559d07c1e6ffcc3c

Contents?: true

Size: 538 Bytes

Versions: 5

Compression:

Stored size: 538 Bytes

Contents

module Refinery
  module Authentication
    module Devise
      class Role < Refinery::Core::BaseModel

        has_and_belongs_to_many :users, :join_table => :refinery_authentication_devise_roles_users

        before_validation :camelize_title
        validates :title, :uniqueness => true

        def camelize_title(role_title = self.title)
          self.title = role_title.to_s.camelize
        end

        def self.[](title)
          where(:title => title.to_s.camelize).first_or_create!
        end

      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
refinerycms-authentication-devise-1.0.4 app/models/refinery/authentication/devise/role.rb
refinerycms-authentication-devise-1.0.3 app/models/refinery/authentication/devise/role.rb
refinerycms-authentication-devise-1.0.2 app/models/refinery/authentication/devise/role.rb
refinerycms-authentication-devise-1.0.1 app/models/refinery/authentication/devise/role.rb
refinerycms-authentication-devise-1.0.0 app/models/refinery/authentication/devise/role.rb