Class: Lolita::Configuration::Action
- Includes:
- Builder
- Defined in:
- lib/lolita/configuration/action.rb
Instance Attribute Summary collapse
- #html(attributes = nil) ⇒ Object
-
#name ⇒ Object
readonly
Returns the value of attribute name.
- #title(value = nil) ⇒ Object
Instance Method Summary collapse
-
#initialize(dbi, name, options = {}, &block) ⇒ Action
constructor
A new instance of Action.
- #view_url(view, record) ⇒ Object
Methods included from Builder
#build, #builder, #builder=, #builder_default_name, #builder_default_options, #builder_default_state
Constructor Details
#initialize(dbi, name, options = {}, &block) ⇒ Action
Returns a new instance of Action.
10 11 12 13 14 15 16 17 |
# File 'lib/lolita/configuration/action.rb', line 10 def initialize(dbi,name, ={}, &block) @dbi = dbi @name = name .each do |key,value| self.send(:"#{key}=",value) end instance_eval(&block) if block_given? end |
Instance Attribute Details
#html(attributes = nil) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/lolita/configuration/action.rb', line 19 def html attributes = nil if attributes @html = attributes else result = {} (@html || {}).each{|k,v| result[k] = v.respond_to?(:call) ? v.call : v } result end end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/lolita/configuration/action.rb', line 8 def name @name end |
#title(value = nil) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/lolita/configuration/action.rb', line 31 def title value=nil if value @title = value else if @title @title.respond_to?(:call) ? @title.call : @title else ::I18n.t("#{@dbi.klass.to_s.underscore}.actions.#{@name}") end end end |
Instance Method Details
#view_url(view, record) ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/lolita/configuration/action.rb', line 43 def view_url view, record if @url.respond_to?(:call) @url.call(view,record) else @url end end |