Sha256: 9b6b87a84c62779fe683d1a7d389ec61abbd39fa6ada46e34ae72156201b204e
Contents?: true
Size: 702 Bytes
Versions: 31
Compression:
Stored size: 702 Bytes
Contents
module JsonApiClient module Associations module BelongsTo extend ActiveSupport::Concern module ClassMethods def belongs_to(attr_name, options = {}) # self.associations = self.associations + [HasOne::Association.new(attr_name, self, options)] self.associations += [BelongsTo::Association.new(attr_name, self, options)] end end class Association < BaseAssociation def parse(params) params ? association_class.new(params) : nil end def param :"#{attr_name}_id" end def to_prefix_path "#{attr_name.to_s.pluralize}/%{#{param}}" end end end end end
Version data entries
31 entries across 31 versions & 1 rubygems