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

#initialize ⇒ AttributeResourceType

Returns a new instance of AttributeResourceType.



126
127
128
# File 'app/models/ability.rb', line 126

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

Instance Method Details

#actions ⇒ Object



130
131
132
133
134
135
# File 'app/models/ability.rb', line 130

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

#compare(resource_object, resource_name) ⇒ Object



137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# File 'app/models/ability.rb', line 137

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