Sha256: 55f61dc733a9cc6ed90d9ac3f5ea65755f7ff5c9f9e69597d417d753fc8fdd29

Contents?: true

Size: 1.25 KB

Versions: 25

Compression:

Stored size: 1.25 KB

Contents

module Graphiti
  class Serializer < JSONAPI::Serializable::Resource
    include Graphiti::Extensions::BooleanAttribute
    include Graphiti::Extensions::ExtraAttribute
    include Graphiti::SerializableHash
    prepend Graphiti::SerializableTempId

    # Keep track of what attributes have been applied by the Resource,
    # via .attribute, and which have been applied by a custom serializer
    # class/file.
    # This way, we can ensure attributes NOT applied by a resource still
    # go through type checking/coercion
    class_attribute :attributes_applied_via_resource
    class_attribute :extra_attributes_applied_via_resource
    self.attributes_applied_via_resource = []
    self.extra_attributes_applied_via_resource = []

    def self.inherited(klass)
      super
      klass.class_eval do
        extend JSONAPI::Serializable::Resource::ConditionalFields
      end
    end

    # Temporary fix until fixed upstream
    # https://github.com/jsonapi-rb/jsonapi-serializable/pull/102
    def requested_relationships(fields)
      @_relationships
    end

    # Allow access to resource methods
    def method_missing(id, *args, &blk)
      if @resource.respond_to?(id, true)
        @resource.send(id, *args, &blk)
      else
        super
      end
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
graphiti-1.0.beta.11 lib/graphiti/serializer.rb
graphiti-1.0.beta.10 lib/graphiti/serializer.rb
graphiti-1.0.beta.9 lib/graphiti/serializer.rb
graphiti-1.0.beta.8 lib/graphiti/serializer.rb
graphiti-1.0.beta.7 lib/graphiti/serializer.rb
graphiti-1.0.beta.6 lib/graphiti/serializer.rb
graphiti-1.0.beta.5 lib/graphiti/serializer.rb
graphiti-1.0.beta.4 lib/graphiti/serializer.rb
graphiti-1.0.beta.3 lib/graphiti/serializer.rb
graphiti-1.0.beta.2 lib/graphiti/serializer.rb
graphiti-1.0.alpha.26 lib/graphiti/serializer.rb
graphiti-1.0.alpha.25 lib/graphiti/serializer.rb
graphiti-1.0.alpha.24 lib/graphiti/serializer.rb
graphiti-1.0.alpha.23 lib/graphiti/serializer.rb
graphiti-1.0.alpha.22 lib/graphiti/serializer.rb
graphiti-1.0.alpha.21 lib/graphiti/serializer.rb
graphiti-1.0.alpha.20 lib/graphiti/serializer.rb
graphiti-1.0.alpha.19 lib/graphiti/serializer.rb
graphiti-1.0.alpha.18 lib/graphiti/serializer.rb
graphiti-1.0.alpha.17 lib/graphiti/serializer.rb