Module: Aws::Record::Attributes
- Included in:
- Aws::Record
- Defined in:
- lib/aws-record/record/attributes.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(attr_values = {}) ⇒ Aws::Record
Base initialization method for a new item.
-
#to_h ⇒ Hash
Returns a hash representation of the attribute data.
Class Method Details
.included(sub_class) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/aws-record/record/attributes.rb', line 18 def self.included(sub_class) sub_class.extend(ClassMethods) model_attributes = ModelAttributes.new(self) sub_class.instance_variable_set("@attributes", model_attributes) sub_class.instance_variable_set("@keys", KeyAttributes.new(model_attributes)) end |
Instance Method Details
#initialize(attr_values = {}) ⇒ Aws::Record
Base initialization method for a new item. Optionally, allows you to provide initial attribute values for the model. You do not need to provide all, or even any, attributes at item creation time.
42 43 44 45 46 47 48 49 50 |
# File 'lib/aws-record/record/attributes.rb', line 42 def initialize(attr_values = {}) opts = { track_mutations: self.class.mutation_tracking_enabled? } @data = ItemData.new(self.class.attributes, opts) attr_values.each do |attr_name, attr_value| send("#{attr_name}=", attr_value) end end |
#to_h ⇒ Hash
Returns a hash representation of the attribute data.
55 56 57 |
# File 'lib/aws-record/record/attributes.rb', line 55 def to_h @data.hash_copy end |