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

#attributes

Instance Method Summary collapse

Methods included from DocumentComposition

prohibited_methods

Methods included from Stateful

#destroyed?, #flagged_for_destroy?, #new_record?, #persisted?, #readonly?, #settable?, #updateable?

Methods included from Persistable

#save

Methods included from HashKey

#keys_as_selector

Methods included from Fields

#database_field_name, option, options

Methods included from Changeable

#changes

Methods included from Expected

#request_as_new_record

Methods included from Attributes

#attribute_missing?, #process_attribute, #process_attributes, #read_attribute, #typed_value_for, #write_attribute

Methods included from Attributes::Readonly

#attribute_writable?

Instance Method Details

#deleteObject



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,

Examples:

Create a new document.

Person.new(hash_key: hash_key, title: "Sir")

Parameters:

  • attrs (Hash) (defaults to: nil)

    The attributes to set up the document with.

Returns:

Since:

  • 1.0.0



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