Sha256: a1f1127b77565d61b1ff43952845f6673a2292826ccda9c12b6aca13a2b18c33

Contents?: true

Size: 484 Bytes

Versions: 5

Compression:

Stored size: 484 Bytes

Contents

::Gorillib::Model::Field.class_eval do
  field :fixup, Symbol, doc: 'key to remap before receive', tester: true
end

module ::Gorillib::StringFixup
  extend Gorillib::Concern
  
  # intercept to replace fixup-able hash keys with the proper field name in the receive hash
  def receive!(hsh={})
    self.class.fields.each do |field_name, field|
      next unless field.fixup?
      hsh[field_name] = hsh.delete(field.fixup) if hsh.has_key?(field.fixup)
    end
    super(hsh)
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
gorillib-0.6.0 lib/gorillib/model/fixup.rb
gorillib-0.5.2 lib/gorillib/model/fixup.rb
gorillib-0.5.0 lib/gorillib/model/fixup.rb
gorillib-0.4.2 lib/gorillib/model/fixup.rb
gorillib-0.4.2pre lib/gorillib/model/fixup.rb