diff --git a/lib/modis/attribute.rb b/lib/modis/attribute.rb index eeb77d0..1e18942 100644 --- a/lib/modis/attribute.rb +++ b/lib/modis/attribute.rb @@ -19,8 +19,6 @@ def self.included(base) module ClassMethods def bootstrap_attributes(parent = nil) - attr_reader :attributes - class << self attr_accessor :attributes, :attributes_with_defaults end @@ -73,6 +71,10 @@ def #{name}=(value) end end + def attributes + @modis_attributes + end + def assign_attributes(hash) hash.each do |k, v| setter = "#{k}=" @@ -96,12 +98,8 @@ def set_sti_type write_attribute(:type, self.class.name) end - def reset_changes - @changed_attributes = nil - end - def apply_defaults - @attributes = Hash[self.class.attributes_with_defaults] + @modis_attributes = Hash[self.class.attributes_with_defaults] end end end diff --git a/lib/modis/model.rb b/lib/modis/model.rb index 07e3e25..2dbb765 100644 --- a/lib/modis/model.rb +++ b/lib/modis/model.rb @@ -35,7 +35,7 @@ def initialize(record = nil, options = {}) apply_defaults set_sti_type assign_attributes(record) if record - reset_changes + changes_applied return unless options.key?(:new_record) diff --git a/lib/modis/persistence.rb b/lib/modis/persistence.rb index 881d6a0..400425b 100644 --- a/lib/modis/persistence.rb +++ b/lib/modis/persistence.rb @@ -180,7 +180,7 @@ def create_or_update(args = {}) future = persist if future && (future == :unchanged || future.value == 'OK') - reset_changes + changes_applied @new_record = false true else diff --git a/modis.gemspec b/modis.gemspec index ff8528c..8706661 100644 --- a/modis.gemspec +++ b/modis.gemspec @@ -18,8 +18,8 @@ Gem::Specification.new do |gem| gem.test_files = gem.files.grep(%r{^(test|spec|features)/}) gem.require_paths = ["lib"] - gem.add_runtime_dependency 'activemodel', ['>= 3.0', '< 5.2'] - gem.add_runtime_dependency 'activesupport', ['>= 3.0', '< 5.2'] + gem.add_runtime_dependency 'activemodel', ['>= 3.0'] + gem.add_runtime_dependency 'activesupport', ['>= 3.0'] gem.add_runtime_dependency 'redis', '>= 3.0' gem.add_runtime_dependency 'hiredis', '>= 0.5' gem.add_runtime_dependency 'connection_pool', '>= 2'