Class: Archangel::Liquid::Drop
- Inherits:
-
Liquid::Drop
- Object
- Liquid::Drop
- Archangel::Liquid::Drop
- Defined in:
- lib/archangel/liquid/drop.rb
Overview
Liquid Drop for singular resources
Direct Known Subclasses
Archangel::Liquid::Drops::PageDrop, Archangel::Liquid::Drops::SiteDrop
Class Attribute Summary collapse
-
._associations ⇒ Object
Returns the value of attribute _associations.
-
._attributes ⇒ Object
Returns the value of attribute _attributes.
Class Method Summary collapse
-
.attributes(*attrs) ⇒ Object
Build attributes.
Instance Method Summary collapse
-
#as_json(options = {}) ⇒ Object
Object as JSON.
-
#attributes ⇒ Hash
Hash of attributes.
-
#initialize(object, _options = {}) ⇒ Drop
constructor
Initialize.
-
#inspect ⇒ String
Object inspect.
-
#to_json(options = {}) ⇒ Object
Object to JSON.
Constructor Details
#initialize(object, _options = {}) ⇒ Drop
Initialize
40 41 42 |
# File 'lib/archangel/liquid/drop.rb', line 40 def initialize(object, = {}) @object = object end |
Class Attribute Details
._associations ⇒ Object
Returns the value of attribute _associations.
13 14 15 |
# File 'lib/archangel/liquid/drop.rb', line 13 def _associations @_associations end |
._attributes ⇒ Object
Returns the value of attribute _attributes.
14 15 16 |
# File 'lib/archangel/liquid/drop.rb', line 14 def _attributes @_attributes end |
Class Method Details
.attributes(*attrs) ⇒ Object
Build attributes
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/archangel/liquid/drop.rb', line 25 def self.attributes(*attrs) @_attributes.concat attrs attrs.each do |attr| next if method_defined?(attr) define_method(attr) do object.send(attr) if object.methods.include?(attr) end end end |
Instance Method Details
#as_json(options = {}) ⇒ Object
Object as JSON
61 62 63 |
# File 'lib/archangel/liquid/drop.rb', line 61 def as_json( = {}) attributes.as_json() end |
#attributes ⇒ Hash
Hash of attributes
49 50 51 52 53 54 |
# File 'lib/archangel/liquid/drop.rb', line 49 def attributes @attributes ||= self.class._attributes.dup.each_with_object({}) do |name, hash| hash[name.to_s] = send(name) end end |
#inspect ⇒ String
Object inspect
79 80 81 82 |
# File 'lib/archangel/liquid/drop.rb', line 79 def inspect "#<#{self.class.name} " \ "@object: #{object.inspect} @attributes: #{attributes.inspect}>" end |
#to_json(options = {}) ⇒ Object
Object to JSON
70 71 72 |
# File 'lib/archangel/liquid/drop.rb', line 70 def to_json( = {}) as_json.to_json() end |