Sha256: 0cb0f2feb05599acc6c9b2718149249b253082363d5f813a37540a1031224933
Contents?: true
Size: 681 Bytes
Versions: 2
Compression:
Stored size: 681 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
hal_api-rails-0.2.1 | lib/hal_api/representer/link_serialize.rb |
hal_api-rails-0.2.0 | lib/hal_api/representer/link_serialize.rb |