module HalApi::Representer::Curies::ClassMethods
Constants
- LINK_RELATIONS
Public Instance Methods
collection(name, options={})
click to toggle source
Calls superclass method
# File lib/hal_api/representer/curies.rb, line 57 def collection(name, options={}) options[:as] = curify(options[:as] || name) if options[:embedded] super(name, options) end
curies(curie, &block)
click to toggle source
# File lib/hal_api/representer/curies.rb, line 29 def curies(curie, &block) use_curie(curie) unless default_curie link({rel: :curies, array: true}) do if represented.try(:show_curies) block.call end end end
curify(rel, curie=default_curie)
click to toggle source
# File lib/hal_api/representer/curies.rb, line 38 def curify(rel, curie=default_curie) if curie.blank? || rel.to_s =~ /:/ || LINK_RELATIONS.include?(rel.to_s) rel else "#{curie}:#{rel}".to_sym end end
link(options, &block)
click to toggle source
Calls superclass method
# File lib/hal_api/representer/curies.rb, line 46 def link(options, &block) options = {:rel => options} unless options.is_a?(Hash) options[:rel] = curify(options[:rel]) super(options, &block) end
property(name, options={})
click to toggle source
Calls superclass method
# File lib/hal_api/representer/curies.rb, line 52 def property(name, options={}) options[:as] = curify(options[:as] || name) if options[:embedded] super(name, options) end
use_curie(curie)
click to toggle source
# File lib/hal_api/representer/curies.rb, line 25 def use_curie(curie) self.default_curie = curie end