Sha256: f8179567b868d9708e08c89509faa3eece82fb64cabaef9871730ea2023691aa

Contents?: true

Size: 655 Bytes

Versions: 3

Compression:

Stored size: 655 Bytes

Contents

class RestModel
  class Embeddable < Association
    autoload :Sender,    "rest_model/key/embeddable/sender"
    autoload :Retriever, "rest_model/key/embeddable/retriever"
    autoload :Response,  "rest_model/key/embeddable/response"
    include   Sender
    include   Retriever
    include   Response

    attr_accessor :fields

    def initialize(name, options = {})
      super

      if fields = options[:fields]
        @class_name = :array
        @fields = fields
      end
    end

    def raw?
      %w(Hash Array).include?(@class_name.to_s.camelize)
    end

    def from_hash(attrs, resource = nil)
      raw? ? attrs : super
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rest_model-0.3.1 lib/rest_model/key/embeddable.rb
rest_model-0.3.0 lib/rest_model/key/embeddable.rb
rest_model-0.2.3 lib/rest_model/key/embeddable.rb