Class: Goaltender::ValueParser::BelongsTo

Inherits:
Goaltender::ValueParser show all
Defined in:
lib/goaltender/value_parser/belongs_to.rb

Instance Attribute Summary collapse

Attributes inherited from Goaltender::ValueParser

#input_value

Instance Method Summary collapse

Methods inherited from Goaltender::ValueParser

#initialize

Constructor Details

This class inherits a constructor from Goaltender::ValueParser

Instance Attribute Details

#form_classObject (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_nameObject (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

#parseObject



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