Sha256: dfc2556b2219bb446a203f0914dd4c1040dae7c53859b84288e3f6028b99fb07

Contents?: true

Size: 686 Bytes

Versions: 6

Compression:

Stored size: 686 Bytes

Contents

module Arrest
  class HasManySubResourceAttribute < HasManyAttribute
    alias :super_from_hash :from_hash

    def initialize(ids_field_name,
                   method_name,
                   clazz_name,
                   url_part,
                   foreign_key)
      # the read_only is set to true to avoid sending post request as ids array in JSON
      # directly instead of modifying the ids via the sub_resource
      super(ids_field_name, method_name, clazz_name, url_part, foreign_key, true)
    end

    def sub_resource_field_name
      @name
    end

    def from_hash(parent, value)
      return [] if value == nil
      super_from_hash(parent, value)
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
arrest-0.0.31 lib/arrest/attributes/has_many_sub_resource_attribute.rb
arrest-0.0.30 lib/arrest/attributes/has_many_sub_resource_attribute.rb
arrest-0.0.29 lib/arrest/attributes/has_many_sub_resource_attribute.rb
arrest-0.0.28 lib/arrest/attributes/has_many_sub_resource_attribute.rb
arrest-0.0.27 lib/arrest/attributes/has_many_sub_resource_attribute.rb
arrest-0.0.25 lib/arrest/attributes/has_many_sub_resource_attribute.rb