Sha256: b7313a84e445b371b73b5ea28664406ca0b205d6f73e48e97d64d45a4fb3eccd

Contents?: true

Size: 455 Bytes

Versions: 4

Compression:

Stored size: 455 Bytes

Contents

module Ivy
  module Serializers
    module Relationships
      class Relationship
        def initialize(name, options={}, &getter)
          @name = name
          @options = options
          @getter = getter || method(:default_getter)
        end

        private

        def default_getter(resource)
          resource.public_send(@name)
        end

        def get(resource)
          @getter.call(resource)
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ivy-serializers-0.4.0 lib/ivy/serializers/relationships/relationship.rb
ivy-serializers-0.3.0 lib/ivy/serializers/relationships/relationship.rb
ivy-serializers-0.2.0 lib/ivy/serializers/relationships/relationship.rb
ivy-serializers-0.1.0 lib/ivy/serializers/relationships/relationship.rb