Class: Ability::AttributeResourceType

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

#initializeAttributeResourceType

Returns a new instance of AttributeResourceType.



139
140
141
# File 'app/models/ability.rb', line 139

def initialize
  super(::Attribute, 'Attribute')
end

Instance Method Details

#actionsObject



143
144
145
146
147
148
# File 'app/models/ability.rb', line 143

def actions
  [
    :show,  #Full WebGIS access
    :edit  #Edit in admin backend or spatial editing (implies [:show])
  ]
end

#compare(resource_object, resource_name) ⇒ Object



150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# File 'app/models/ability.rb', line 150

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