simple_model 1.2.9 → 1.2.10

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -2,4 +2,6 @@ source "https://rubygems.org"
2
2
 
3
3
 
4
4
  # Specify your gem's dependencies in simple_model.gemspec
5
- gemspec
5
+ gemspec
6
+
7
+ #gem 'debugger'
@@ -113,7 +113,7 @@ module SimpleModel
113
113
  end
114
114
 
115
115
  def alias_attributes
116
- @alias_attributes ||= {}.with_indifferent_access
116
+ @alias_attributes ||= HashWithIndifferentAccess.new
117
117
  end
118
118
 
119
119
  def alias_attributes=alias_attributes
@@ -121,13 +121,17 @@ module SimpleModel
121
121
  end
122
122
 
123
123
  def defined_attributes
124
- @defined_attributes ||= {}.with_indifferent_access
124
+ @defined_attributes ||= HashWithIndifferentAccess.new
125
125
  end
126
126
 
127
127
  def defined_attributes=defined_attributes
128
128
  @defined_attributes = defined_attributes
129
129
  end
130
130
 
131
+ def attribute_defined?(attr)
132
+ (self.defined_attributes[attr] || self.superclass.respond_to?(:attribute_defined?) && self.superclass.attribute_defined?(attr))
133
+ end
134
+
131
135
  # The default settings for a SimpeModel class
132
136
  # Options:
133
137
  # * :on_set - accepts a lambda that is run when an attribute is set
@@ -283,11 +287,6 @@ module SimpleModel
283
287
  base.attribute_method_suffix '_changed?', '_change', '_will_change!', '_was'
284
288
  base.attribute_method_affix :prefix => 'reset_', :suffix => '!'
285
289
  end
286
- base.defined_attributes = self.defined_attributes.merge(base.defined_attributes)
287
- base.alias_attributes = self.alias_attributes.merge(base.alias_attributes)
288
- base.defined_attributes.each do |attr,options|
289
- base.create_attribute_methods([attr],options) #unless base.instance_methods.include?(attr.to_sym)
290
- end
291
290
  end
292
291
  end
293
292
 
@@ -1,3 +1,3 @@
1
1
  module SimpleModel
2
- VERSION = "1.2.9"
2
+ VERSION = "1.2.10"
3
3
  end
@@ -246,7 +246,7 @@ describe SimpleModel::Attributes do
246
246
  end
247
247
  end
248
248
  it "should merge defined attributes when class are inhereted" do
249
- NewerBase.defined_attributes[:bar].should_not be_nil
249
+ NewerBase.attribute_defined?(:bar).should be_true
250
250
  n = NewerBase.new
251
251
  n.respond_to?(:bar_will_change!).should be_true
252
252
  end
@@ -254,6 +254,8 @@ describe SimpleModel::Attributes do
254
254
  it "should defaults that were not initialized should work from parent class" do
255
255
  n = NewerBase.new
256
256
  n.some.should eql(Date.today)
257
+ n.some = "2012-12-01"
258
+ n.some.should be_a(Date)
257
259
  n.thing.should eql(Date.today)
258
260
  end
259
261
 
@@ -218,8 +218,8 @@ describe SimpleModel do
218
218
 
219
219
  end
220
220
  it "should merge defined attributes when class are inhereted" do
221
- NewTestStuff.defined_attributes[:bar].blank?.should be_false
222
- NewTestStuff.defined_attributes[:foo].blank?.should be_false
221
+ NewTestStuff.attribute_defined?(:bar).blank?.should be_false
222
+ NewTestStuff.attribute_defined?(:foo).blank?.should be_false
223
223
  end
224
224
  it "should merge defined attributes when class are inhereted" do
225
225
  TestStuff.new.respond_to?(:bar_will_change!).should be_true
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_model
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.9
4
+ version: 1.2.10
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: