Module: Wrest::Components::Container::Typecaster::InstanceMethods

Defined in:
lib/wrest/components/container/typecaster.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#initialize_with_typecasting(attributes = {}) ⇒ Object



163
164
165
166
167
168
169
170
171
172
173
# File 'lib/wrest/components/container/typecaster.rb', line 163

def initialize_with_typecasting(attributes = {})
  # :nodoc:
  initialize_without_typecasting(attributes)
  self.class.typecast_map.each do |key, typecaster|
    value = @attributes[key]
    if value.is_a?(String) || value.is_a?(Hash) || value.is_a?(Array)
      @attributes[key] =
        typecaster.call(value)
    end
  end
end