Sha256: 7502014e853085fb27a6c74958514d4046583211926bd534e5cff19ccb5ab586
Contents?: true
Size: 730 Bytes
Versions: 8
Compression:
Stored size: 730 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) || ->(represented:, doc:, **) do try("#{name}_id=", id_from_url(doc[pname])) if doc[pname] Representable::Pipeline::Stop end property(pname, readable: false, reader: reader) end end end end
Version data entries
8 entries across 8 versions & 1 rubygems