Class: Netzke::Core::ActionConfig

Inherits:
DslConfigBase
  • Object
show all
Defined in:
lib/netzke/core/action_config.rb

Overview

This class is responsible for configuring an action. It is passed as a block parameter to the action DSL method:

class MyComponent < Netzke::Base
  action :do_something do |c|
    c.text = "Do it!"
    c.tooltip = "Do something"
    c.icon = :tick
  end
end

Instance Method Summary collapse

Constructor Details

#initialize(name, component) ⇒ ActionConfig

Returns a new instance of ActionConfig



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/netzke/core/action_config.rb', line 12

def initialize(name, component)
  super

  @text = @tooltip = @icon = ""

  build_localized_attributes

  self.text = @text.presence || @name.humanize
  self.tooltip = @tooltip.presence || @name.humanize
  self.icon = @icon.to_sym if @icon.present?
end

Instance Method Details

#set_defaults!Object



24
25
26
# File 'lib/netzke/core/action_config.rb', line 24

def set_defaults!
  self[:icon] = icon.is_a?(Symbol) ? Netzke::Base.uri_to_icon(icon) : icon
end