class TPX_2_2::DataModel

The base class for a TPX dictionary/hash.

Public Class Methods

new(input_hash) click to toggle source

Overrides the default initialize to validate the input data.

@param input_hash [Hash] The input hash.

@return [DataModel] The returned object.

Calls superclass method
# File lib/tpx/2_2/data_model.rb, line 17
def initialize(input_hash)
  unless input_hash.is_a? Hash
    raise ValidationError, "Parameter `input_hash` supplied to #{self.class} must be of type Hash (#{input_hash.class}: #{input_hash.inspect})!"
  end
  super input_hash
  validate!
end

Public Instance Methods

to_h() click to toggle source

Overrides the default to_h method to return a hash with symbolized keys.

@return [Object] The returned hash.

# File lib/tpx/2_2/data_model.rb, line 28
def to_h
  self.symbolize_keys.to_h
end