Class: PDC::Resource::ValueParser

Inherits:
Object
  • Object
show all
Defined in:
lib/pdc/resource/value_parser.rb

Overview

Internal ValueParser takes in a value and returns the parsed form of the input e.g. Hash gets converted to OpenStruct so that foo: {

bar: {
  too: 'too moo',
  baz: {
    value: 'foobarbaz'
  }
}

} can be accessed as foo.bar.too and foo.bar.baz.value

Class Method Summary collapse

Class Method Details

.parse(value) ⇒ Object



16
17
18
19
20
21
# File 'lib/pdc/resource/value_parser.rb', line 16

def parse(value)
  if value.is_a?(Array) then value.map { |v| parse(v) }
  elsif value.is_a?(Hash) then OpenStruct.new(parse_hash(value))
  else value
  end
end