Module: TinyDyno::Document
- Extended by:
- ActiveModel::Naming, ActiveSupport::Concern
- Includes:
- ActiveModel::Dirty, ActiveModel::Model, DocumentComposition
- Defined in:
- lib/tiny_dyno/document.rb
Defined Under Namespace
Modules: ClassMethods
Constant Summary
Constants included from DocumentComposition
TinyDyno::DocumentComposition::MODULES
Instance Attribute Summary
Attributes included from Stateful
#destroyed, #flagged_for_destroy, #new_record
Attributes included from Attributes
Instance Method Summary collapse
- #delete ⇒ Object
-
#initialize(attrs = nil) ⇒ Document
Instantiate a new
Document, setting the Document’s attributes if given.
Methods included from DocumentComposition
Methods included from Stateful
#destroyed?, #flagged_for_destroy?, #new_record?, #persisted?, #readonly?, #settable?, #updateable?
Methods included from Persistable
Methods included from HashKey
Methods included from Fields
#database_field_name, option, options
Methods included from Changeable
Methods included from Expected
Methods included from Attributes
#attribute_missing?, #process_attribute, #process_attributes, #read_attribute, #typed_value_for, #write_attribute
Methods included from Attributes::Readonly
Instance Method Details
#delete ⇒ Object
40 41 42 |
# File 'lib/tiny_dyno/document.rb', line 40 def delete request_delete end |
#initialize(attrs = nil) ⇒ Document
Instantiate a new Document, setting the Document’s attributes if given. If no attributes are provided, they will be initialized with an empty Hash.
The Hash Key must currently be provided from the applicationIf a HashKey is defined, the document’s id will be set to that key,
30 31 32 33 34 35 36 37 38 |
# File 'lib/tiny_dyno/document.rb', line 30 def initialize(attrs = nil) @new_record = true @attributes ||= {} process_attributes(attrs) do yield(self) if block_given? end # run_callbacks(:initialize) unless _initialize_callbacks.empty? # raise ::TinyDyno::Errors::MissingHashKey.new(self.name) unless @hash_key.is_a?(Hash) end |