Module: DHS::Data::Becomes

Extended by:
ActiveSupport::Concern
Included in:
DHS::Data
Defined in:
lib/dhs/concerns/data/becomes.rb

Instance Method Summary collapse

Instance Method Details

#becomes(klass, options = {}) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/dhs/concerns/data/becomes.rb', line 10

def becomes(klass, options = {})
  return self if self.instance_of?(klass) && !is_a?(DHS::Data)
  data = DHS::Data.new(_raw, _parent, klass)
  data.errors = options[:errors] if options[:errors]
  data.warnings = options[:warnings] if options[:warnings]
  klass.new(data)
end