Class: Tool

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Validations
Defined in:
app/models/tool.rb

Constant Summary collapse

ALL =
['LineMeasureTool', 'AreaMeasureTool',
'PrevTool', 'NextTool', 'LinkTool', 'PrintTool',
'ExportTool', 'SelectTool']

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(topic, name) ⇒ Tool

Returns a new instance of Tool.



12
13
14
# File 'app/models/tool.rb', line 12

def initialize(topic, name)
  @topic, @name = topic, name
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



10
11
12
# File 'app/models/tool.rb', line 10

def name
  @name
end

#topicObject

Returns the value of attribute topic.



10
11
12
# File 'app/models/tool.rb', line 10

def topic
  @topic
end

Class Method Details

.accessible_tools(topic, ability) ⇒ Object



16
17
18
19
20
21
22
# File 'app/models/tool.rb', line 16

def self.accessible_tools(topic, ability)
  tools = ALL.select do |tool|
    ability.can?(:show, Tool.new(topic, tool))
  end
  tools << 'EditTool' if ability.can?(:edit, topic)
  tools
end