Module: DynamodbRecord::Document

Extended by:
ActiveSupport::Concern
Includes:
Associations, Fields, Finders, Persistence, Query
Defined in:
lib/dynamodb_record/document.rb

Defined Under Namespace

Modules: ClassMethods

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Persistence

#destroy, #save, #save!

Methods included from Fields

#read_attribute, #write_attribute

Instance Attribute Details

#new_recordObject

Returns the value of attribute new_record.



23
24
25
# File 'lib/dynamodb_record/document.rb', line 23

def new_record
  @new_record
end

Instance Method Details

#initialize(params = {}, ignore_unknown_field = false) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/dynamodb_record/document.rb', line 25

def initialize(params = {}, ignore_unknown_field = false)
  @new_record = true
  @attributes = {} # Validar esta linea

  # Set default
  self.class.attributes.each do |key, value|
    send("#{key}=", value[:options][:default]) if value[:options][:default]
  end

  load(params, ignore_unknown_field)
end

#load(params, ignore_unknown_field = false) ⇒ Object



37
38
39
40
41
42
43
# File 'lib/dynamodb_record/document.rb', line 37

def load(params, ignore_unknown_field = false)
  params.each do |key, value|
    next if ignore_unknown_field && !respond_to?("#{key}=")

    send("#{key}=", value)
  end
end