class Yaks::Resource
Public Class Methods
new(attrs = {})
click to toggle source
Calls superclass method
# File lib/yaks/resource.rb, line 13 def initialize(attrs = {}) raise attrs.inspect if attrs.key?(:subresources) && !attrs[:subresources].instance_of?(Array) super end
Public Instance Methods
[](attr)
click to toggle source
# File lib/yaks/resource.rb, line 18 def [](attr) attributes[attr] end
add_form(form)
click to toggle source
# File lib/yaks/resource.rb, line 80 def add_form(form) append_to(:forms, form) end
add_link(link)
click to toggle source
# File lib/yaks/resource.rb, line 76 def add_link(link) append_to(:links, link) end
add_rel(rel)
click to toggle source
# File lib/yaks/resource.rb, line 72 def add_rel(rel) append_to(:rels, rel) end
add_subresource(subresource)
click to toggle source
# File lib/yaks/resource.rb, line 84 def add_subresource(subresource) append_to(:subresources, subresource) end
collection?()
click to toggle source
# File lib/yaks/resource.rb, line 46 def collection? false end
Also aliased as: collection
find_form(name)
click to toggle source
# File lib/yaks/resource.rb, line 22 def find_form(name) forms.find { |form| form.name.equal? name } end
members()
click to toggle source
# File lib/yaks/resource.rb, line 59 def members raise UnsupportedOperationError, "Only Yaks::CollectionResource has members" end
merge_attributes(new_attrs)
click to toggle source
# File lib/yaks/resource.rb, line 67 def merge_attributes(new_attrs) with(attributes: @attributes.merge(new_attrs)) end
null_resource?()
click to toggle source
# File lib/yaks/resource.rb, line 55 def null_resource? false end
self_link()
click to toggle source
# File lib/yaks/resource.rb, line 30 def self_link # This reverse is there so that the last :self link specified # "wins". The use case is having a self link defined in a base # mapper class, but having it overridden in specific # subclasses. In combination with formats that expect resources # to have up to one self link, this is the preferred behavior. # However since 0.7.5 links take a "replace: true" option to # specifiy they should replace previous defintions with the same # rel, wich should be used instead. The behavior that the last # link "wins" will be deprecated, the result of multiple links # with the same rel will be unspecified. links.reverse.find do |link| link.rel.equal? :self end end
seq()
click to toggle source
# File lib/yaks/resource.rb, line 26 def seq [self] end
with_collection(*)
click to toggle source
# File lib/yaks/resource.rb, line 51 def with_collection(*) self end