Sha256: 850f91d2e570563750b2072c3408644d15db04798005aa7cf2c5f2247dd77a18
Contents?: true
Size: 678 Bytes
Versions: 21
Compression:
Stored size: 678 Bytes
Contents
require 'active_support/concern' module HalApi::Representer::LinkSerialize extend ActiveSupport::Concern module ClassMethods def link(options, &block) set_link_property(options) super(options, &block) end def set_link_property(options) if options.is_a?(Hash) && (options.delete(:writeable) || options[:reader]) name = options[:rel].to_s.split(':').last.split('/').last pname = "set_#{name}_uri" reader = options.delete(:reader) || ->(doc, _args) do try("#{name}_id=", id_from_url(doc[pname])) if doc[pname] end property(pname, readable: false, reader: reader) end end end end
Version data entries
21 entries across 21 versions & 1 rubygems