Module: ORMivore::Entity
- Included in:
- App::Account, App::Address
- Defined in:
- lib/ormivore/entity.rb
Defined Under Namespace
Modules: ClassMethods
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
152 153 154 |
# File 'lib/ormivore/entity.rb', line 152 def id @id end |
Class Method Details
.included(base) ⇒ Object
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
# File 'lib/ormivore/entity.rb', line 125 def self.included(base) base.extend(ClassMethods) base.module_eval(<<-EOS) class Builder def initialize @attributes = {} end def id attributes[:id] end def adapter=(value) @adapter = value end # FactoryGirl integration point def save! @attributes = @adapter.create(attributes) end attr_reader :attributes end EOS end |
Instance Method Details
#apply(attrs) ⇒ Object
162 163 164 165 166 |
# File 'lib/ormivore/entity.rb', line 162 def apply(attrs) self.dup.tap { |other| other.(attrs) } end |
#attributes ⇒ Object
154 155 156 |
# File 'lib/ormivore/entity.rb', line 154 def attributes all_attributes end |
#changes ⇒ Object
158 159 160 |
# File 'lib/ormivore/entity.rb', line 158 def changes @dirty_attributes end |