Class: Almodovar::ResourcePresenter::Link
- Inherits:
-
Object
- Object
- Almodovar::ResourcePresenter::Link
- Defined in:
- lib/almodovar-server/resource_presenter/link.rb
Defined Under Namespace
Classes: JsonSerializer, Serializer, XmlSerializer
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#expand_args ⇒ Object
readonly
Returns the value of attribute expand_args.
-
#expand_resource ⇒ Object
readonly
Returns the value of attribute expand_resource.
-
#href ⇒ Object
readonly
Returns the value of attribute href.
-
#rel ⇒ Object
readonly
Returns the value of attribute rel.
Instance Method Summary collapse
- #as_json(options = {}) ⇒ Object
- #expand_resource? ⇒ Boolean
-
#initialize(*args) ⇒ Link
constructor
A new instance of Link.
- #resource ⇒ Object
- #resource_collection ⇒ Object
- #resource_collection? ⇒ Boolean
- #single_resource ⇒ Object
- #to_xml(options = {}) ⇒ Object
Constructor Details
#initialize(*args) ⇒ Link
Returns a new instance of Link.
7 8 9 10 |
# File 'lib/almodovar-server/resource_presenter/link.rb', line 7 def initialize(*args) @rel, @href, @expand_resource, @expand_args, @attributes = args @attributes ||= {} end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
5 6 7 |
# File 'lib/almodovar-server/resource_presenter/link.rb', line 5 def attributes @attributes end |
#expand_args ⇒ Object (readonly)
Returns the value of attribute expand_args.
5 6 7 |
# File 'lib/almodovar-server/resource_presenter/link.rb', line 5 def @expand_args end |
#expand_resource ⇒ Object (readonly)
Returns the value of attribute expand_resource.
5 6 7 |
# File 'lib/almodovar-server/resource_presenter/link.rb', line 5 def @expand_resource end |
#href ⇒ Object (readonly)
Returns the value of attribute href.
5 6 7 |
# File 'lib/almodovar-server/resource_presenter/link.rb', line 5 def href @href end |
#rel ⇒ Object (readonly)
Returns the value of attribute rel.
5 6 7 |
# File 'lib/almodovar-server/resource_presenter/link.rb', line 5 def rel @rel end |
Instance Method Details
#as_json(options = {}) ⇒ Object
16 17 18 |
# File 'lib/almodovar-server/resource_presenter/link.rb', line 16 def as_json( = {}) JsonSerializer.new(self, ).as_json end |
#expand_resource? ⇒ Boolean
36 37 38 |
# File 'lib/almodovar-server/resource_presenter/link.rb', line 36 def .present? end |
#resource ⇒ Object
20 21 22 |
# File 'lib/almodovar-server/resource_presenter/link.rb', line 20 def resource resource_collection? ? resource_collection : single_resource end |
#resource_collection ⇒ Object
28 29 30 |
# File 'lib/almodovar-server/resource_presenter/link.rb', line 28 def resource_collection ResourcePresenter::Collection.new(, ) end |
#resource_collection? ⇒ Boolean
24 25 26 |
# File 'lib/almodovar-server/resource_presenter/link.rb', line 24 def resource_collection? .is_a?(Array) end |
#single_resource ⇒ Object
32 33 34 |
# File 'lib/almodovar-server/resource_presenter/link.rb', line 32 def single_resource .new(*[].compact) end |
#to_xml(options = {}) ⇒ Object
12 13 14 |
# File 'lib/almodovar-server/resource_presenter/link.rb', line 12 def to_xml( = {}) XmlSerializer.new(self, .merge(:skip_instruct => true)).to_xml end |