Module: ORMivore::Entity

Included in:
App::Account, App::Address
Defined in:
lib/ormivore/entity.rb

Defined Under Namespace

Modules: ClassMethods

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#idObject (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("    class Builder\n      def initialize\n        @attributes = {}\n      end\n\n      def id\n        attributes[:id]\n      end\n\n      def adapter=(value)\n        @adapter = value\n      end\n\n      # FactoryGirl integration point\n      def save!\n        @attributes = @adapter.create(attributes)\n      end\n\n      attr_reader :attributes\n    end\n  EOS\nend\n")

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.expand_changes(attrs)
  }
end

#attributesObject



154
155
156
# File 'lib/ormivore/entity.rb', line 154

def attributes
  all_attributes
end

#changesObject



158
159
160
# File 'lib/ormivore/entity.rb', line 158

def changes
  @dirty_attributes
end