Class: Ability::LayerResourceType

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?, #role_can?, #roles_can?, #roles_permissions

Constructor Details

#initializeLayerResourceType

Returns a new instance of LayerResourceType.



84
85
86
# File 'app/models/ability.rb', line 84

def initialize
  super(Layer, 'Layer')
end

Instance Method Details

#actionsObject



88
89
90
91
92
93
94
95
# File 'app/models/ability.rb', line 88

def actions
  [
    :show,  #Full WebGIS access
    :edit,  #Edit in admin backend or spatial editing (implies [:show, :legend, :query])
    :legend, # Show legend (implies [:show])
    :query  #Allow identify/search (implies [:show])
  ]
end

#compare(resource_object, resource_name) ⇒ Object



101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'app/models/ability.rb', line 101

def compare(resource_object, resource_name)
  topic, layer = resource_name.split('/')
  if topic == '*'
    if layer == '*'
      true
    else
      resource_object.name == layer
    end
  else
    if layer == '*'
      layer_topics_lookup[resource_object.id].include?(topic)
    else
      resource_object.name == layer && layer_topics_lookup[resource_object.id].include?(topic)
    end
  end
end

#resourcesObject



97
98
99
# File 'app/models/ability.rb', line 97

def resources
  Layer.select("id,name")
end