Module: Authorization::ObjectRolesTable::ModelExtensions::ClassMethods

Defined in:
lib/rails-authorization-plugin/lib/publishare/object_roles_table.rb

Instance Method Summary collapse

Instance Method Details

#accepted_roles_by(user) ⇒ Object


155
156
157
# File 'lib/rails-authorization-plugin/lib/publishare/object_roles_table.rb', line 155

def accepted_roles_by(user)
  user.roles_for self
end

#accepts_no_role(role_name, user) ⇒ Object


146
147
148
# File 'lib/rails-authorization-plugin/lib/publishare/object_roles_table.rb', line 146

def accepts_no_role(role_name, user)
  user.has_no_role role_name, self
end

#accepts_role(role_name, user) ⇒ Object


142
143
144
# File 'lib/rails-authorization-plugin/lib/publishare/object_roles_table.rb', line 142

def accepts_role(role_name, user)
  user.has_role role_name, self
end

#accepts_role?(role_name, user) ⇒ Boolean


138
139
140
# File 'lib/rails-authorization-plugin/lib/publishare/object_roles_table.rb', line 138

def accepts_role?(role_name, user)
  user.has_role? role_name, self
end

#accepts_roles_by?(user) ⇒ Boolean


150
151
152
# File 'lib/rails-authorization-plugin/lib/publishare/object_roles_table.rb', line 150

def accepts_roles_by?(user)
  user.has_roles_for? self
end

#acts_as_authorizableObject


133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# File 'lib/rails-authorization-plugin/lib/publishare/object_roles_table.rb', line 133

def acts_as_authorizable
  has_many :accepted_roles, as: :authorizable, class_name: 'Role', dependent: :destroy

  has_many :users, through: :roles

  def accepts_role?(role_name, user)
    user.has_role? role_name, self
  end

  def accepts_role(role_name, user)
    user.has_role role_name, self
  end

  def accepts_no_role(role_name, user)
    user.has_no_role role_name, self
  end

  def accepts_roles_by?(user)
    user.has_roles_for? self
  end
  alias :accepts_role_by? :accepts_roles_by?

  def accepted_roles_by(user)
    user.roles_for self
  end

  def authorizables_by(user)
    user.authorizables_for self
  end

  include Authorization::ObjectRolesTable::ModelExtensions::InstanceMethods
  include Authorization::Identity::ModelExtensions::InstanceMethods # Provides all kinds of dynamic sugar via method_missing
end

#authorizables_by(user) ⇒ Object


159
160
161
# File 'lib/rails-authorization-plugin/lib/publishare/object_roles_table.rb', line 159

def authorizables_by(user)
  user.authorizables_for self
end