Module: Dddr::Entity
- Defined in:
- lib/dddr.rb
Instance Attribute Summary collapse
-
#created_at ⇒ Object
Returns the value of attribute created_at.
-
#deleted ⇒ Object
Returns the value of attribute deleted.
-
#deleted_at ⇒ Object
Returns the value of attribute deleted_at.
-
#last_updated_at ⇒ Object
Returns the value of attribute last_updated_at.
-
#uid ⇒ Object
Returns the value of attribute uid.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#created_at ⇒ Object
Returns the value of attribute created_at.
93 94 95 |
# File 'lib/dddr.rb', line 93 def created_at @created_at end |
#deleted ⇒ Object
Returns the value of attribute deleted.
93 94 95 |
# File 'lib/dddr.rb', line 93 def deleted @deleted end |
#deleted_at ⇒ Object
Returns the value of attribute deleted_at.
93 94 95 |
# File 'lib/dddr.rb', line 93 def deleted_at @deleted_at end |
#last_updated_at ⇒ Object
Returns the value of attribute last_updated_at.
93 94 95 |
# File 'lib/dddr.rb', line 93 def last_updated_at @last_updated_at end |
#uid ⇒ Object
Returns the value of attribute uid.
93 94 95 |
# File 'lib/dddr.rb', line 93 def uid @uid end |
Class Method Details
.create_properties(*names) ⇒ Object
59 60 61 62 63 |
# File 'lib/dddr.rb', line 59 def self.create_properties(*names) names.each do |name| attr_accessor name end end |
.included(base) ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/dddr.rb', line 65 def self.included(base) if Dddr.configuration.engine == :sdbm Dddr::ENTITIES << base include Dddr::Sdbm base.extend(Dddr::Sdbm::ClassMethods) end if Dddr.configuration.engine == :sequel include Dddr::Sequel base.extend(Dddr::Sequel::ClassMethods) end end |
Instance Method Details
#from_hash(uid, data_hash) ⇒ Object
85 86 87 88 89 90 |
# File 'lib/dddr.rb', line 85 def from_hash(uid, data_hash) self.uid = uid data_hash.each do |attribute, value| send(:"#{attribute}=", value) if respond_to?(:"#{attribute}=") end end |
#new? ⇒ Boolean
95 96 97 |
# File 'lib/dddr.rb', line 95 def new? created_at.nil? end |
#to_hash ⇒ Object
79 80 81 82 83 |
# File 'lib/dddr.rb', line 79 def to_hash instance_variables.each_with_object({}) do |var, hash| hash[var.to_s.delete("@").to_sym] = instance_variable_get(var) end end |