ascheink-active_yaml 0.0.6 → 0.0.7

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/README.rdoc CHANGED
@@ -1,6 +1,6 @@
1
1
  = active_yaml
2
2
 
3
- Access data from a YAML file as if it were ActiveRecord.
3
+ Treat YAML like ActiveRecord. Metaprogramming FTW.
4
4
 
5
5
  == Copyright
6
6
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.6
1
+ 0.0.7
data/active_yaml.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{active_yaml}
5
- s.version = "0.0.6"
5
+ s.version = "0.0.7"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Andrei Scheinkman"]
data/lib/active_yaml.rb CHANGED
@@ -24,15 +24,25 @@ class ActiveYAML
24
24
  end
25
25
  end
26
26
  end
27
- class_eval "def self.find(id); find_by_id(id) or raise ActiveRecord::RecordNotFound; end"
28
- class_eval "def self.first; @instances.first; end"
29
- class_eval "def self.last; @instances.last; end"
30
- class_eval "def self.each; @instances.each { |b| yield b }; end"
27
+ @instances.freeze
31
28
  s = "#{p.to_s}(#{fields.join(', ')})"
32
29
  class_eval "def self.to_s; \"#{s}\"; end"
30
+
33
31
  def self.find_all
34
32
  @instances
35
33
  end
34
+ def self.find(id)
35
+ find_by_id(id) or raise ActiveRecord::RecordNotFound
36
+ end
37
+ def self.first
38
+ @instances.first
39
+ end
40
+ def self.last
41
+ @instances.last
42
+ end
43
+ def self.each
44
+ @instances.each { |b| yield b }
45
+ end
36
46
  end
37
47
  end
38
48
  end
@@ -70,5 +70,11 @@ class ActiveYamlTest < Test::Unit::TestCase
70
70
  should "support enumerable" do
71
71
  assert_equal 14951385, City.inject(0) { |a, c| a + c.population }
72
72
  end
73
+ should "freeze contents" do
74
+ assert_raises(TypeError) do
75
+ a = City.find_all
76
+ a << 1
77
+ end
78
+ end
73
79
  end
74
80
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ascheink-active_yaml
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrei Scheinkman