Class: Goaltender::ValueParser::BelongsTo
- Inherits:
-
Goaltender::ValueParser
- Object
- Goaltender::ValueParser
- Goaltender::ValueParser::BelongsTo
- Defined in:
- lib/goaltender/value_parser/belongs_to.rb
Instance Attribute Summary collapse
-
#form_class ⇒ Object
readonly
Returns the value of attribute form_class.
-
#variable_name ⇒ Object
readonly
Returns the value of attribute variable_name.
Attributes inherited from Goaltender::ValueParser
Instance Method Summary collapse
Methods inherited from Goaltender::ValueParser
Constructor Details
This class inherits a constructor from Goaltender::ValueParser
Instance Attribute Details
#form_class ⇒ Object (readonly)
Returns the value of attribute form_class.
5 6 7 |
# File 'lib/goaltender/value_parser/belongs_to.rb', line 5 def form_class @form_class end |
#variable_name ⇒ Object (readonly)
Returns the value of attribute variable_name.
5 6 7 |
# File 'lib/goaltender/value_parser/belongs_to.rb', line 5 def variable_name @variable_name end |
Instance Method Details
#after_init(args) ⇒ Object
7 8 9 10 |
# File 'lib/goaltender/value_parser/belongs_to.rb', line 7 def after_init(args) @form_class = args[:form_class] @variable_name = args[:variable_name] end |
#parse ⇒ Object
12 13 14 15 |
# File 'lib/goaltender/value_parser/belongs_to.rb', line 12 def parse return input_value unless input_value.present? form_class.constantize.new(input_value).to_h end |