rep 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 79a33f37e6f9081705b5913b390bc60105188d60
4
- data.tar.gz: 35c6b05b07523f9a1419980141ed9c17baed89e0
3
+ metadata.gz: 7f4c932a45e402490a81a1d6e0091dc027549b9a
4
+ data.tar.gz: 83551aa64194875830cd0cacdfd7c185b89aedb3
5
5
  SHA512:
6
- metadata.gz: 6e1c6080327e17f7cd90affcc168c3193375c994fbfd9a208631f087aa467d1e09d6aebd8b1916341190657c66c968cbbb4fd32702a8b86bf8a11d3174401e84
7
- data.tar.gz: e86a7a76a786d98a8fbb4d8504075b90df005fe51271cf076c1e67bd44d5ac0f7a1b43cee5708c9245f7a42250b106af6c991ef040d9575481b7847fbb9ec827
6
+ metadata.gz: 313a387c25f6b66d6dd7eb81c189b9099a332ac08f9bf388259ada7e4f42d8f6672f517919ebbf95e6a39ff6a1db067e0cba33a81d7c706f56185dc170001991
7
+ data.tar.gz: bdd1693a3780387b6d975b4c709723e44abdbc73ea8d5fe26a2baa247a09dc08bdecf90d7aa6b978a98084ddeec3dcde54a7456bfebd1d804dd8dbe305b0e503
@@ -1,11 +1,10 @@
1
1
  language: ruby
2
2
  rvm:
3
- - "1.8.7"
4
- - "1.9.2"
5
3
  - "1.9.3"
4
+ - "2.0.0"
6
5
  # - jruby-18mode # JRuby in 1.8 mode
7
6
  # - jruby-19mode # JRuby in 1.9 mode
8
7
  # - rbx-18mode
9
- # - rbx-19mode
8
+ - rbx-19mode
10
9
  # uncomment this line if your project needs to run something other than `rake`:
11
10
  # script: bundle exec rspec spec
data/lib/rep.rb CHANGED
@@ -119,7 +119,7 @@ module Rep
119
119
  # If your class already has an `#iniatialize` method then this will overwrite it (so don't use it). `#initialize_with`
120
120
  # does not have to be used to use any other parts of Rep.
121
121
 
122
- def initialize_with(*args)
122
+ def initialize_with(*args, &blk)
123
123
  @initializiation_args = args
124
124
 
125
125
  # Remember what args we normally initialize with so we can refer to them when building shared instances.
@@ -137,8 +137,7 @@ module Rep
137
137
 
138
138
  args.each { |a| register_accessor(a) }
139
139
 
140
- define_method(:initialize) { |*args|
141
- opts = args.first || {}
140
+ define_method(:initialize) { |opts={}|
142
141
  parse_opts(opts)
143
142
  }
144
143
 
@@ -147,6 +146,7 @@ module Rep
147
146
 
148
147
  define_method :parse_opts do |opts|
149
148
  @rep_options = opts
149
+ blk.call(opts) unless blk.nil?
150
150
  self.class.initializiation_args.each do |field|
151
151
  name = field.is_a?(Hash) ? field.to_a.first.first : field
152
152
  instance_variable_set(:"@#{name}", opts[name])
@@ -1,3 +1,3 @@
1
1
  module Rep
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -56,6 +56,16 @@ describe Rep do
56
56
  inst.foo.must_be_nil
57
57
  end
58
58
 
59
+ it "can take a block for initialization custimization" do
60
+ klass = new_rep_class do
61
+ initialize_with :foo do |opts|
62
+ opts[:foo] &&= opts[:foo].to_s
63
+ end
64
+ end
65
+ inst = klass.new(:foo => :bar)
66
+ inst.foo.must_equal 'bar'
67
+ end
68
+
59
69
  it "should accept multiple sets of fields" do
60
70
  klass = new_rep_class do
61
71
  fields [:one, :four] => :default
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rep
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - myobie
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-30 00:00:00.000000000 Z
11
+ date: 2013-10-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake