active_hash 0.9.0 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,11 +1,14 @@
1
+ 2010-12-08
2
+ - ruby 1.9.2 compatibility
3
+
1
4
  2010-12-06
2
- - added dependency on ActiveModel
3
- - add persisted? method to ActiveHash::Base
4
- - ActiveHash::Base#save takes *args to be compatible with ActiveModel
5
- - ActiveHash::Base#to_param returns nil if the object hasn't been saved
5
+ - added dependency on ActiveModel
6
+ - add persisted? method to ActiveHash::Base
7
+ - ActiveHash::Base#save takes *args to be compatible with ActiveModel
8
+ - ActiveHash::Base#to_param returns nil if the object hasn't been saved
6
9
 
7
10
  2010-11-09
8
- - Use Ruby's definition of "word character" (numbers, underscores) when forming ActiveHash::Enum constants (tstuart)
11
+ - Use Ruby's definition of "word character" (numbers, underscores) when forming ActiveHash::Enum constants (tstuart)
9
12
 
10
13
  2010-11-07
11
14
  - Get ActiveHash::Associations to return a scope for has_many active record relationships (mocoso)
@@ -14,23 +17,23 @@
14
17
  - Allow find_by_* methods to accept an options hash, so rails associations don't blow up
15
18
 
16
19
  2010-10-07
17
- - Add conditions to ActiveHash#all (Ryan Garver)
18
- - Add #cache_key to ActiveHash::Base (Tom Stuart)
19
- - Add banged dynamic finder support to ActiveHash::Base (Tom Stuart)
20
+ - Add conditions to ActiveHash#all (Ryan Garver)
21
+ - Add #cache_key to ActiveHash::Base (Tom Stuart)
22
+ - Add banged dynamic finder support to ActiveHash::Base (Tom Stuart)
20
23
 
21
24
  2010-09-16
22
- - Enum format now uses underscores instead of removing all characters
23
- - Removed test dependency on acts_as_fu
25
+ - Enum format now uses underscores instead of removing all characters
26
+ - Removed test dependency on acts_as_fu
24
27
 
25
28
  2010-05-26
26
- - Silence metaclass deprecation warnings in active support 2.3.8
29
+ - Silence metaclass deprecation warnings in active support 2.3.8
27
30
 
28
31
  2010-05-04
29
- - When calling ActiveFile::Base.reload do not actually perform the reload if nothing has been modified unless you call reload(true) to force (Michael Schubert)
32
+ - When calling ActiveFile::Base.reload do not actually perform the reload if nothing has been modified unless you call reload(true) to force (Michael Schubert)
30
33
 
31
34
  2010-04-25
32
- - When ActiveRecord model belongs_to an ActiveHash and the associated id is nil, returns nil instead of raising RecordNotFound (Jeremy Weiskotten)
33
- - Merged Nakajima's "add" alias for "create" - gotta save those ASCII characters :)
35
+ - When ActiveRecord model belongs_to an ActiveHash and the associated id is nil, returns nil instead of raising RecordNotFound (Jeremy Weiskotten)
36
+ - Merged Nakajima's "add" alias for "create" - gotta save those ASCII characters :)
34
37
 
35
38
  2010-03-01
36
39
  - Removed "extend"-related deprecations - they didn't play well with rails class loading
@@ -45,8 +48,7 @@
45
48
  - Calling #belongs_to now creates the underlying field if it's not already there (belongs_to :city will create the :city_id field)
46
49
 
47
50
  2009-12-10
48
- - Fixed a bug where belongs_to associations would raise an error instead of returning
49
- nil when the parent object didn't exist.
51
+ - Fixed a bug where belongs_to associations would raise an error instead of returning nil when the parent object didn't exist.
50
52
  - Added #[] and #[]= accessors for more ActiveRecord-esque-ness. (Pat Nakajima & Dave Yeu)
51
53
 
52
54
  2009-12-01
data/active_hash.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{active_hash}
5
- s.version = "0.9.0"
5
+ s.version = "0.9.1"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = [
@@ -18,9 +18,10 @@ Gem::Specification.new do |s|
18
18
  "Jeremy Weiskotten",
19
19
  "Ryan Garver",
20
20
  "Tom Stuart",
21
- "Joel Chippindale"
21
+ "Joel Chippindale",
22
+ "Kevin Olsen"
22
23
  ]
23
- s.date = %q{2010-12-06}
24
+ s.date = %q{2010-12-08}
24
25
  s.email = %q{jeff@zilkey.com}
25
26
  s.extra_rdoc_files = [
26
27
  "LICENSE",
@@ -173,7 +173,7 @@ module ActiveHash
173
173
  private :configuration_for_custom_finder
174
174
 
175
175
  def define_getter_method(field, default_value)
176
- unless instance_methods.include?(field.to_s)
176
+ unless has_instance_method?(field)
177
177
  define_method(field) do
178
178
  attributes[field].nil? ? default_value : attributes[field]
179
179
  end
@@ -184,7 +184,7 @@ module ActiveHash
184
184
 
185
185
  def define_setter_method(field)
186
186
  method_name = "#{field}="
187
- unless instance_methods.include?(method_name)
187
+ unless has_instance_method?(method_name)
188
188
  define_method(method_name) do |new_val|
189
189
  attributes[field] = new_val
190
190
  end
@@ -194,8 +194,8 @@ module ActiveHash
194
194
  private :define_setter_method
195
195
 
196
196
  def define_interrogator_method(field)
197
- method_name = "#{field}?"
198
- unless instance_methods.include?(method_name)
197
+ method_name = :"#{field}?"
198
+ unless has_instance_method?(method_name)
199
199
  define_method(method_name) do
200
200
  send(field).present?
201
201
  end
@@ -205,8 +205,8 @@ module ActiveHash
205
205
  private :define_interrogator_method
206
206
 
207
207
  def define_custom_find_method(field_name)
208
- method_name = "find_by_#{field_name}"
209
- unless singleton_methods.include?(method_name)
208
+ method_name = :"find_by_#{field_name}"
209
+ unless has_singleton_method?(method_name)
210
210
  the_meta_class.instance_eval do
211
211
  define_method(method_name) do |*args|
212
212
  options = args.extract_options!
@@ -220,8 +220,8 @@ module ActiveHash
220
220
  private :define_custom_find_method
221
221
 
222
222
  def define_custom_find_all_method(field_name)
223
- method_name = "find_all_by_#{field_name}"
224
- unless singleton_methods.include?(method_name)
223
+ method_name = :"find_all_by_#{field_name}"
224
+ unless has_singleton_method?(method_name)
225
225
  the_meta_class.instance_eval do
226
226
  unless singleton_methods.include?(method_name)
227
227
  define_method(method_name) do |*args|
@@ -276,14 +276,26 @@ module ActiveHash
276
276
 
277
277
  private :mark_clean
278
278
 
279
+ def has_instance_method?(name)
280
+ instance_methods.map{|method| method.to_sym}.include?(name)
281
+ end
282
+
283
+ private :has_instance_method?
284
+
285
+ def has_singleton_method?(name)
286
+ singleton_methods.map{|method| method.to_sym}.include?(name)
287
+ end
288
+
289
+ private :has_singleton_method?
290
+
279
291
  end
280
292
 
281
293
  attr_reader :attributes
282
294
 
283
- def initialize(options = {})
284
- options.symbolize_keys!
285
- @attributes = options
286
- options.each do |key, value|
295
+ def initialize(attributes = {})
296
+ attributes.symbolize_keys!
297
+ @attributes = attributes
298
+ attributes.dup.each do |key, value|
287
299
  send "#{key}=", value
288
300
  end
289
301
  end
@@ -692,6 +692,11 @@ describe ActiveHash, "Base" do
692
692
  end
693
693
  end
694
694
 
695
+ Country.find_by_name("foo").should == "find_by_name defined manually"
696
+ Country.find_all_by_name("foo").should == "find_all_by_name defined manually"
697
+ Country.new.name.should == "name defined manually"
698
+ Country.new.name?.should == "name? defined manually"
699
+
695
700
  Country.data = [
696
701
  {:name => "foo"}
697
702
  ]
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_hash
3
3
  version: !ruby/object:Gem::Version
4
- hash: 59
4
+ hash: 57
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 9
9
- - 0
10
- version: 0.9.0
9
+ - 1
10
+ version: 0.9.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jeff Dean
@@ -23,11 +23,12 @@ authors:
23
23
  - Ryan Garver
24
24
  - Tom Stuart
25
25
  - Joel Chippindale
26
+ - Kevin Olsen
26
27
  autorequire:
27
28
  bindir: bin
28
29
  cert_chain: []
29
30
 
30
- date: 2010-12-06 00:00:00 -07:00
31
+ date: 2010-12-08 00:00:00 -07:00
31
32
  default_executable:
32
33
  dependencies:
33
34
  - !ruby/object:Gem::Dependency