Sha256: fd54d8c2f92a494aaeaa34dbe9219cb5377e25e674755491e47a5f644b793b4e

Contents?: true

Size: 729 Bytes

Versions: 17

Compression:

Stored size: 729 Bytes

Contents

require 'active_support/concern'

module Journey::Resource::AttributeLoading
  extend ActiveSupport::Concern

  included do
    def load(attributes, remove_root = false, persisted = false)
      # 'data' is a reserved key in ActiveResource,
      # but Journey uses it for the Oplog
      attributes['content'] = attributes.delete('data')

      super(attributes, remove_root, persisted).tap do

        # allow enum_sets to be loaded by key (rather than index)
        # by auto-converting them on initialization
        if enum_sets = self.class.instance_variable_get(:@enum_sets)
          enum_sets.each do |enum_attr|
            send("#{enum_attr}=", send(enum_attr))
          end
        end
      end
    end
  end

end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
embark-journey-0.1.5 lib/journey/resource/attribute_loading.rb
embark-journey-0.1.4 lib/journey/resource/attribute_loading.rb
embark-journey-0.1.3 lib/journey/resource/attribute_loading.rb
embark-journey-0.1.1 lib/journey/resource/attribute_loading.rb
embark-journey-0.1.0 lib/journey/resource/attribute_loading.rb
embark-journey-0.0.29 lib/journey/resource/attribute_loading.rb
embark-journey-0.0.28 lib/journey/resource/attribute_loading.rb
embark-journey-0.0.27 lib/journey/resource/attribute_loading.rb
embark-journey-0.0.26 lib/journey/resource/attribute_loading.rb
embark-journey-0.0.25 lib/journey/resource/attribute_loading.rb
embark-journey-0.0.24 lib/journey/resource/attribute_loading.rb
embark-journey-0.0.23 lib/journey/resource/attribute_loading.rb
embark-journey-0.0.22 lib/journey/resource/attribute_loading.rb
embark-journey-0.0.21 lib/journey/resource/attribute_loading.rb
embark-journey-0.0.20 lib/journey/resource/attribute_loading.rb
embark-journey-0.0.19 lib/journey/resource/attribute_loading.rb
embark-journey-0.0.18 lib/journey/resource/attribute_loading.rb