Class: Yaks::Resource
- Inherits:
-
Object
show all
- Extended by:
- Util::Deprecated
- Defined in:
- lib/yaks/resource.rb,
lib/yaks/resource/form.rb,
lib/yaks/resource/link.rb,
lib/yaks/resource/form/field.rb,
lib/yaks/resource/has_fields.rb,
lib/yaks/resource/form/legend.rb,
lib/yaks/resource/form/fieldset.rb,
lib/yaks/resource/form/field/option.rb
Defined Under Namespace
Modules: HasFields
Classes: Form, Link
Instance Method Summary
collapse
deprecated_alias
Constructor Details
#initialize(attrs = {}) ⇒ Resource
Returns a new instance of Resource.
13
14
15
16
|
# File 'lib/yaks/resource.rb', line 13
def initialize(attrs = {})
raise attrs.inspect if attrs.key?(:subresources) && !attrs[:subresources].instance_of?(Array)
super
end
|
Instance Method Details
#[](attr) ⇒ Object
18
19
20
|
# File 'lib/yaks/resource.rb', line 18
def [](attr)
attributes[attr]
end
|
80
81
82
|
# File 'lib/yaks/resource.rb', line 80
def add_form(form)
append_to(:forms, form)
end
|
#add_link(link) ⇒ Object
76
77
78
|
# File 'lib/yaks/resource.rb', line 76
def add_link(link)
append_to(:links, link)
end
|
#add_rel(rel) ⇒ Object
72
73
74
|
# File 'lib/yaks/resource.rb', line 72
def add_rel(rel)
append_to(:rels, rel)
end
|
#add_subresource(subresource) ⇒ Object
84
85
86
|
# File 'lib/yaks/resource.rb', line 84
def add_subresource(subresource)
append_to(:subresources, subresource)
end
|
#collection? ⇒ Boolean
Also known as:
collection
46
47
48
|
# File 'lib/yaks/resource.rb', line 46
def collection?
false
end
|
22
23
24
|
# File 'lib/yaks/resource.rb', line 22
def find_form(name)
forms.find { |form| form.name.equal? name }
end
|
#members ⇒ Object
Also known as:
each, map, each_with_object, with_members
59
60
61
|
# File 'lib/yaks/resource.rb', line 59
def members
raise UnsupportedOperationError, "Only Yaks::CollectionResource has members"
end
|
#merge_attributes(new_attrs) ⇒ Object
67
68
69
|
# File 'lib/yaks/resource.rb', line 67
def merge_attributes(new_attrs)
with(attributes: @attributes.merge(new_attrs))
end
|
#null_resource? ⇒ Boolean
55
56
57
|
# File 'lib/yaks/resource.rb', line 55
def null_resource?
false
end
|
#self_link ⇒ Object
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/yaks/resource.rb', line 30
def self_link
links.reverse.find do |link|
link.rel.equal? :self
end
end
|
#seq ⇒ Object
26
27
28
|
# File 'lib/yaks/resource.rb', line 26
def seq
[self]
end
|
#with_collection ⇒ Object
51
52
53
|
# File 'lib/yaks/resource.rb', line 51
def with_collection(*)
self
end
|