collector 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -55,7 +55,7 @@ Models automatically create and update timestamps for `created_at` and `updated_
55
55
 
56
56
  ### Repositories
57
57
 
58
- Include `Collector::Repository` in your repository objects to turn them into repositories. Use the same inflection as your model's name (singular).
58
+ Include `Collector::Repository` in an object to turn it into a repository for a model of the same name. Use the same inflection as your model's name (singular).
59
59
 
60
60
  ```ruby
61
61
  class PickleRepository
@@ -72,6 +72,10 @@ pickle = Pickle.new(brine: "vinegar", started_at: Time.now)
72
72
  PickleRepository.save(pickle)
73
73
  ```
74
74
 
75
+ ### Requirements
76
+
77
+ Collector will only work with 1.9.x and above. Specifically it's tested with 1.9.2 and 1.9.3.
78
+
75
79
  ## Contributing
76
80
 
77
81
  1. Fork it
@@ -10,12 +10,10 @@ module Collector
10
10
  def initialize(attributes = {})
11
11
  attributes.symbolize_keys!
12
12
 
13
- attributes.each do |attribute, value|
14
- send("#{attribute}=", value) if methods.include? "#{attribute}=".to_sym
13
+ attributes.each do |key, value|
14
+ instance_variable_set("@#{key}", value) if methods.include? "#{key}".to_sym
15
+ send("#{key}=", value) if methods.include? "#{key}=".to_sym
15
16
  end
16
-
17
- instance_variable_set("@created_at", attributes[:created_at]) if attributes[:created_at]
18
- instance_variable_set("@updated_at", attributes[:updated_at]) if attributes[:updated_at]
19
17
  end
20
18
 
21
19
  def touch
@@ -1,3 +1,3 @@
1
1
  module Collector
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
@@ -9,15 +9,15 @@ describe Collector::Model do
9
9
  end
10
10
  end
11
11
 
12
- it "sets attributes during initialization if a writer exists" do
12
+ it "sets attributes via instance variable during initialization if a reader exists" do
13
13
  TestModel.send(:attr_reader, :foo)
14
- TestModel.send(:attr_writer, :foo)
15
14
  TestModel.new(foo: "bar").foo.must_equal "bar"
16
15
  end
17
16
 
18
- it "does not set attributes during initialization if a writer does not exist" do
17
+ it "sets attributes via writer if a writer exists" do
19
18
  TestModel.send(:attr_reader, :foo)
20
- TestModel.new(foo: "bar").foo.must_be_nil
19
+ TestModel.send(:attr_writer, :foo)
20
+ TestModel.new(foo: "bar").foo.must_equal "bar"
21
21
  end
22
22
 
23
23
  it "has a created_at and updated_at timestamp" do
@@ -27,13 +27,6 @@ describe Collector::Model do
27
27
  test_model.created_at.must_equal now
28
28
  end
29
29
 
30
- it "sets timestamps via instance variables during initialization" do
31
- now = Time.now
32
- test_model = TestModel.new(created_at: now, updated_at: now)
33
- test_model.created_at.must_equal now
34
- test_model.updated_at.must_equal now
35
- end
36
-
37
30
  describe "#touch" do
38
31
  it "sets the timestamps" do
39
32
  Timecop.freeze
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: collector
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-13 00:00:00.000000000 Z
12
+ date: 2012-11-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport