Class: Tool
- Inherits:
-
Object
- Object
- Tool
- 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
-
#name ⇒ Object
Returns the value of attribute name.
-
#topic ⇒ Object
Returns the value of attribute topic.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(topic, name) ⇒ Tool
constructor
A new instance of Tool.
Constructor Details
#initialize(topic, name) ⇒ Tool
12 13 14 |
# File 'app/models/tool.rb', line 12 def initialize(topic, name) @topic, @name = topic, name end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
10 11 12 |
# File 'app/models/tool.rb', line 10 def name @name end |
#topic ⇒ Object
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 |