Module: DynaModel::Attributes::ClassMethods
- Defined in:
- lib/dyna_model/attributes.rb
Instance Method Summary collapse
-
#binary_attr(name, options = {}) ⇒ Object
Adds a DynamoDB binary attribute to this class.
-
#boolean_attr(name, options = {}) ⇒ Object
Adds a boolean attribute to this class.
-
#date_attr(name, options = {}) ⇒ Object
Adds a date attribute to this class.
-
#datetime_attr(name, options = {}) ⇒ Object
Adds a datetime attribute to this class.
-
#float_attr(name, options = {}) ⇒ Object
Adds a float attribute to this class.
-
#integer_attr(name, options = {}) ⇒ Object
Adds an integer attribute to this class.
- #serialized_attr(name, options = {}) ⇒ Object
-
#string_attr(name, options = {}) ⇒ Object
Adds a string attribute to this class.
-
#timestamps ⇒ Object
A convenience method for adding the standard two datetime attributes ‘:created_at` and `:updated_at`.
Instance Method Details
#binary_attr(name, options = {}) ⇒ Object
This should not be used for large objects.
Adds a DynamoDB binary attribute to this class. A binary attribute acts the same as a string attribute, except
157 158 |
# File 'lib/dyna_model/attributes.rb', line 157 def binary_attr name, = {} end |
#boolean_attr(name, options = {}) ⇒ Object
Adds a boolean attribute to this class.
86 87 88 89 90 91 92 93 94 95 |
# File 'lib/dyna_model/attributes.rb', line 86 def boolean_attr name, = {} attr = add_attribute(AWS::Record::Attributes::BooleanAttr.new(name, )) # add the boolean question mark method define_method("#{attr.name}?") do !!__send__(attr.name) end end |
#date_attr(name, options = {}) ⇒ Object
Adds a date attribute to this class.
141 142 143 |
# File 'lib/dyna_model/attributes.rb', line 141 def date_attr name, = {} add_attribute(AWS::Record::Attributes::DateAttr.new(name, )) end |
#datetime_attr(name, options = {}) ⇒ Object
Adds a datetime attribute to this class.
If you add a datetime_attr for ‘:created_at` and/or `:updated_at` those will be automanaged.
118 119 120 |
# File 'lib/dyna_model/attributes.rb', line 118 def datetime_attr name, = {} add_attribute(AWS::Record::Attributes::DateTimeAttr.new(name, )) end |
#float_attr(name, options = {}) ⇒ Object
65 66 67 |
# File 'lib/dyna_model/attributes.rb', line 65 def float_attr name, = {} add_attribute(AWS::Record::Attributes::FloatAttr.new(name, )) end |
#integer_attr(name, options = {}) ⇒ Object
48 49 50 |
# File 'lib/dyna_model/attributes.rb', line 48 def integer_attr name, = {} add_attribute(AWS::Record::Attributes::IntegerAttr.new(name, )) end |
#serialized_attr(name, options = {}) ⇒ Object
160 161 162 |
# File 'lib/dyna_model/attributes.rb', line 160 def serialized_attr name, = {} add_attribute(AWS::Record::Attributes::SerializedAttr.new(name, )) end |
#string_attr(name, options = {}) ⇒ Object
Adds a string attribute to this class.
31 32 33 |
# File 'lib/dyna_model/attributes.rb', line 31 def string_attr name, = {} add_attribute(AWS::Record::Attributes::StringAttr.new(name, )) end |
#timestamps ⇒ Object
A convenience method for adding the standard two datetime attributes ‘:created_at` and `:updated_at`.
178 179 180 181 182 |
# File 'lib/dyna_model/attributes.rb', line 178 def c = datetime_attr :created_at u = datetime_attr :updated_at [c, u] end |