Class: ShadyDB::Document
- Inherits:
-
Object
- Object
- ShadyDB::Document
- Extended by:
- ActiveModel::Callbacks
- Includes:
- ActiveModel::Validations, Attributes, Finders, Persistence
- Defined in:
- lib/shadydb/document.rb
Instance Method Summary collapse
-
#initialize(attribs = {}) ⇒ Document
constructor
A new instance of Document.
- #to_key ⇒ Object
- #to_model ⇒ Object
- #to_param ⇒ Object
Methods included from Persistence
#destroy, #destroyed?, included, #new_record?, #path, #persisted?, #save, #update_attributes
Methods included from Finders
Methods included from Attributes
#[], #[]=, #id, included, #method_missing
Constructor Details
#initialize(attribs = {}) ⇒ Document
Returns a new instance of Document.
12 13 14 15 16 17 18 |
# File 'lib/shadydb/document.rb', line 12 def initialize(attribs = {}) @new_record = true @destroyed = false self.attributes = attribs.stringify_keys self.attributes.reverse_merge!(self.class.fields) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class ShadyDB::Attributes
Instance Method Details
#to_key ⇒ Object
28 29 30 |
# File 'lib/shadydb/document.rb', line 28 def to_key persisted? ? [id] : nil end |
#to_model ⇒ Object
20 21 22 |
# File 'lib/shadydb/document.rb', line 20 def to_model self end |
#to_param ⇒ Object
24 25 26 |
# File 'lib/shadydb/document.rb', line 24 def to_param id end |