Module: LHS::Data::Becomes

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

Instance Method Summary collapse

Instance Method Details

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


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

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