Class: Upmin::Parameter
- Inherits:
-
Object
- Object
- Upmin::Parameter
- Defined in:
- lib/upmin/parameter.rb
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #form_id ⇒ Object
-
#initialize(action, parameter_name, options = {}) ⇒ Parameter
constructor
A new instance of Parameter.
- #label_name ⇒ Object
- #model ⇒ Object
- #nil_form_id ⇒ Object
- #title ⇒ Object
- #type ⇒ Object
Constructor Details
#initialize(action, parameter_name, options = {}) ⇒ Parameter
Returns a new instance of Parameter.
6 7 8 9 10 |
# File 'lib/upmin/parameter.rb', line 6 def initialize(action, parameter_name, = {}) @action = action @name = parameter_name.to_sym @type = [:type] if [:type] end |
Instance Attribute Details
#action ⇒ Object (readonly)
Returns the value of attribute action.
3 4 5 |
# File 'lib/upmin/parameter.rb', line 3 def action @action end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/upmin/parameter.rb', line 4 def name @name end |
Instance Method Details
#form_id ⇒ Object
32 33 34 |
# File 'lib/upmin/parameter.rb', line 32 def form_id return "#{action.name}_#{name}" end |
#label_name ⇒ Object
20 21 22 |
# File 'lib/upmin/parameter.rb', line 20 def label_name name.to_s.capitalize.gsub("_", " ") end |
#model ⇒ Object
12 13 14 |
# File 'lib/upmin/parameter.rb', line 12 def model return action.model end |
#nil_form_id ⇒ Object
36 37 38 |
# File 'lib/upmin/parameter.rb', line 36 def nil_form_id return "#{form_id}_is_nil" end |
#title ⇒ Object
16 17 18 |
# File 'lib/upmin/parameter.rb', line 16 def title return name.to_s.humanize end |
#type ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/upmin/parameter.rb', line 24 def type return @type if defined?(@type) @type = action.model.method(action.name).parameters.select do |param_type, param_name| param_name == name end.first.first || :req return @type end |