active_hash 0.8.1 → 0.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +3 -0
- data/Gemfile +3 -2
- data/VERSION +1 -1
- data/active_hash.gemspec +5 -4
- data/lib/active_hash/base.rb +6 -2
- data/spec/spec_helper.rb +4 -2
- metadata +3 -3
data/CHANGELOG
CHANGED
data/Gemfile
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
source :gemcutter
|
2
2
|
|
3
|
-
gem "activerecord", "3.
|
4
|
-
gem "activesupport", "3.
|
3
|
+
gem "activerecord", ">= 2.3.8", :require => "active_record"
|
4
|
+
gem "activesupport", ">= 2.3.8"
|
5
5
|
gem "rspec", ">= 1.3.0"
|
6
6
|
gem "fixjour", "0.4.1"
|
7
7
|
gem "acts_as_fu", "0.0.5"
|
8
8
|
gem "jeweler", "1.4.0"
|
9
|
+
gem "sqlite3-ruby", ">= 1.2.5"
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.8.
|
1
|
+
0.8.2
|
data/active_hash.gemspec
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{active_hash}
|
8
|
-
s.version = "0.8.
|
8
|
+
s.version = "0.8.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Jeff Dean", "Mike Dalessio", "Corey Innis", "Peter Jaros", "Brandon Keene", "Brian Takita", "Pat Nakajima", "John Pignata", "Michael Schubert", "Jeremy Weiskotten"]
|
12
|
-
s.date = %q{2010-05-
|
12
|
+
s.date = %q{2010-05-26}
|
13
13
|
s.email = %q{jeff@zilkey.com}
|
14
14
|
s.extra_rdoc_files = [
|
15
15
|
"LICENSE",
|
@@ -71,3 +71,4 @@ Gem::Specification.new do |s|
|
|
71
71
|
s.add_dependency(%q<activesupport>, [">= 2.2.2"])
|
72
72
|
end
|
73
73
|
end
|
74
|
+
|
data/lib/active_hash/base.rb
CHANGED
@@ -8,6 +8,10 @@ module ActiveHash
|
|
8
8
|
class << self
|
9
9
|
attr_reader :field_names
|
10
10
|
|
11
|
+
def the_meta_class
|
12
|
+
respond_to?(:singleton_class) ? singleton_class : metaclass
|
13
|
+
end
|
14
|
+
|
11
15
|
def data=(array_of_hashes)
|
12
16
|
mark_dirty
|
13
17
|
@records = nil
|
@@ -173,7 +177,7 @@ module ActiveHash
|
|
173
177
|
def define_custom_find_method(field_name)
|
174
178
|
method_name = "find_by_#{field_name}"
|
175
179
|
unless singleton_methods.include?(method_name)
|
176
|
-
|
180
|
+
the_meta_class.instance_eval do
|
177
181
|
define_method(method_name) do |name|
|
178
182
|
all.detect {|record| record.send(field_name) == name }
|
179
183
|
end
|
@@ -186,7 +190,7 @@ module ActiveHash
|
|
186
190
|
def define_custom_find_all_method(field_name)
|
187
191
|
method_name = "find_all_by_#{field_name}"
|
188
192
|
unless singleton_methods.include?(method_name)
|
189
|
-
|
193
|
+
the_meta_class.instance_eval do
|
190
194
|
unless singleton_methods.include?(method_name)
|
191
195
|
define_method(method_name) do |name|
|
192
196
|
all.select {|record| record.send(field_name) == name }
|
data/spec/spec_helper.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
require 'spec'
|
2
2
|
require 'spec/autorun'
|
3
|
-
require '
|
4
|
-
|
3
|
+
require 'active_record'
|
4
|
+
silence_stream STDERR do
|
5
|
+
require 'acts_as_fu' # suppress activerecord warnings
|
6
|
+
end
|
5
7
|
require 'fixjour'
|
6
8
|
|
7
9
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 8
|
8
|
-
-
|
9
|
-
version: 0.8.
|
8
|
+
- 2
|
9
|
+
version: 0.8.2
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Jeff Dean
|
@@ -23,7 +23,7 @@ autorequire:
|
|
23
23
|
bindir: bin
|
24
24
|
cert_chain: []
|
25
25
|
|
26
|
-
date: 2010-05-
|
26
|
+
date: 2010-05-26 00:00:00 -04:00
|
27
27
|
default_executable:
|
28
28
|
dependencies:
|
29
29
|
- !ruby/object:Gem::Dependency
|