Sha256: e9ed91127f707b62863d4730a3158cdf3c4cea3161bea4c4db3b9de688c0e376

Contents?: true

Size: 498 Bytes

Versions: 1

Compression:

Stored size: 498 Bytes

Contents

module JsonAttributes::LegacyAttributes

  def attributes
    _json_attrs = (self.send(self.class.instance_variable_get(:@field)).try(:dup) || {}).with_indifferent_access

    self.class.instance_variable_get(:@json_attrs).each do |_attribute|
      _json_attrs[_attribute] = nil unless _json_attrs.has_key?(_attribute)
      _json_attrs[_attribute] ||= self.send(_attribute)
    end

    super.merge(_json_attrs).with_indifferent_access.slice!(self.class.instance_variable_get(:@field))
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
json_attributes-0.1.0 lib/json_attributes/legacy_attributes.rb