Class: Ability::ToolResourceType

Inherits:
Permission::ResourceType show all
Defined in:
app/models/ability.rb

Overview


Instance Method Summary collapse

Methods inherited from Permission::ResourceType

#add_ability, for_class, #has_resource_list?, #resources, #role_can?, #roles_can?, #roles_permissions

Constructor Details

#initializeToolResourceType

Returns a new instance of ToolResourceType.



173
174
175
# File 'app/models/ability.rb', line 173

def initialize
  super(Tool, 'Tool')
end

Instance Method Details

#actionsObject



177
178
179
180
181
# File 'app/models/ability.rb', line 177

def actions
  [
    :show  #Tool access
  ]
end

#compare(resource_object, resource_name) ⇒ Object



183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
# File 'app/models/ability.rb', line 183

def compare(resource_object, resource_name)
  topic, attribute = resource_name.split('/')
  if topic == '*'
    if attribute == '*'
      true
    else
      resource_object.name == attribute
    end
  else
    if attribute == '*'
      resource_object.topic.name == topic
    else
      resource_object.name == attribute && resource_object.topic.name == topic
    end
  end
end