Sha256: 907601e7577df92b2888ed9363c7ced7df43e37af92943b1eb7e5c0023ce2153

Contents?: true

Size: 958 Bytes

Versions: 34

Compression:

Stored size: 958 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,
                   read_only)
      # the read_only for the super constructor 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)
      @sub_resource_read_only = read_only
    end

    def sub_resource_field_name
      @name
    end

    # this read only hinders the additional put to the sub resource on saving the encapsulating object
    def sub_resource_read_only?
      @sub_resource_read_only
    end

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

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
arrest-0.0.67 lib/arrest/attributes/has_many_sub_resource_attribute.rb
arrest-0.0.66 lib/arrest/attributes/has_many_sub_resource_attribute.rb
arrest-0.0.65 lib/arrest/attributes/has_many_sub_resource_attribute.rb
arrest-0.0.64 lib/arrest/attributes/has_many_sub_resource_attribute.rb
arrest-0.0.63 lib/arrest/attributes/has_many_sub_resource_attribute.rb
arrest-0.0.62 lib/arrest/attributes/has_many_sub_resource_attribute.rb
arrest-0.0.61 lib/arrest/attributes/has_many_sub_resource_attribute.rb
arrest-0.0.60 lib/arrest/attributes/has_many_sub_resource_attribute.rb
arrest-0.0.59 lib/arrest/attributes/has_many_sub_resource_attribute.rb
arrest-0.0.58 lib/arrest/attributes/has_many_sub_resource_attribute.rb
arrest-0.0.57 lib/arrest/attributes/has_many_sub_resource_attribute.rb
arrest-0.0.56 lib/arrest/attributes/has_many_sub_resource_attribute.rb
arrest-0.0.54 lib/arrest/attributes/has_many_sub_resource_attribute.rb
arrest-0.0.53 lib/arrest/attributes/has_many_sub_resource_attribute.rb
arrest-0.0.52 lib/arrest/attributes/has_many_sub_resource_attribute.rb
arrest-0.0.51 lib/arrest/attributes/has_many_sub_resource_attribute.rb
arrest-0.0.50 lib/arrest/attributes/has_many_sub_resource_attribute.rb
arrest-0.0.49 lib/arrest/attributes/has_many_sub_resource_attribute.rb
arrest-0.0.48 lib/arrest/attributes/has_many_sub_resource_attribute.rb
arrest-0.0.47 lib/arrest/attributes/has_many_sub_resource_attribute.rb