Module: Transcriber::Resource::InputParser

Included in:
Transcriber::Resource
Defined in:
lib/transcriber/resource/input_parser.rb

Instance Method Summary collapse

Instance Method Details

#to_input(options = {}) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/transcriber/resource/input_parser.rb', line 8

def to_input(options = {})
  input = {}
  propagatable_options = {without_nil: options[:without_nil],
                          fail: options[:fail]}

  keys_to_input(options).each do |key|
    value = __send__(key.name)
    key_options = options.fetch(key.name, {}).merge(propagatable_options)
    input.merge! key.to_input!(value, self, key_options)
  end

  input.with_indifferent_access
end

#to_input!(options = {}) ⇒ Object



4
5
6
# File 'lib/transcriber/resource/input_parser.rb', line 4

def to_input!(options = {})
  to_input(options.merge(fail: true))
end