Class: ArangoDb::Document
- Inherits:
-
Object
- Object
- ArangoDb::Document
- Defined in:
- lib/arangodb-odm.rb
Instance Attribute Summary collapse
-
#_id ⇒ Object
Returns the value of attribute _id.
-
#_rev ⇒ Object
Returns the value of attribute _rev.
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#collection ⇒ Object
Returns the value of attribute collection.
-
#db_attrs ⇒ Object
Returns the value of attribute db_attrs.
-
#location ⇒ Object
Returns the value of attribute location.
Instance Method Summary collapse
-
#initialize(collection, db_attrs = []) ⇒ Document
constructor
A new instance of Document.
- #is_new? ⇒ Boolean
- #to_json ⇒ Object
Constructor Details
#initialize(collection, db_attrs = []) ⇒ Document
Returns a new instance of Document.
19 20 21 |
# File 'lib/arangodb-odm.rb', line 19 def initialize(collection, db_attrs = []) @attributes = {}; @collection = collection; @db_attr_names = db_attrs end |
Instance Attribute Details
#_id ⇒ Object
Returns the value of attribute _id.
16 17 18 |
# File 'lib/arangodb-odm.rb', line 16 def _id @_id end |
#_rev ⇒ Object
Returns the value of attribute _rev.
16 17 18 |
# File 'lib/arangodb-odm.rb', line 16 def _rev @_rev end |
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
17 18 19 |
# File 'lib/arangodb-odm.rb', line 17 def attributes @attributes end |
#collection ⇒ Object
Returns the value of attribute collection.
16 17 18 |
# File 'lib/arangodb-odm.rb', line 16 def collection @collection end |
#db_attrs ⇒ Object
Returns the value of attribute db_attrs.
16 17 18 |
# File 'lib/arangodb-odm.rb', line 16 def db_attrs @db_attrs end |
#location ⇒ Object
Returns the value of attribute location.
16 17 18 |
# File 'lib/arangodb-odm.rb', line 16 def location @location end |
Instance Method Details
#is_new? ⇒ Boolean
23 |
# File 'lib/arangodb-odm.rb', line 23 def is_new?; self._id.nil?; end |
#to_json ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/arangodb-odm.rb', line 24 def to_json if @db_attr_names and @db_attr_names.any? values = {} @db_attr_names.each {|a| values[a] = self.attributes[a.to_s]} values.to_json else self.attributes.to_json end end |