options_hash-method_object 0.0.1 → 0.1.0

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: c905985693808cabd9a0925d45c76358664f666e
4
- data.tar.gz: fb96dce849a0ff02ffd34d577b53f391e06b3bfc
3
+ metadata.gz: fdcc77f75cf9408490f84a74b7ef9b158d766b92
4
+ data.tar.gz: 85c3412094c8c5356c98708a53a6c4f6e58d8ad4
5
5
  SHA512:
6
- metadata.gz: 73d3e22e24591b6b2c12640a7c0867ddfb615caf8dcf3d40b61b95cdab2c5c50064f0aa1d68be0c06d7d1ed54048183ba0fa3e04580ee8ebb230c34bb4692bc6
7
- data.tar.gz: f38eff8163adc3294aca7ace796b97301ed62cdf123ce0dbbc6631c22b9492255fdbe260be22eb655dc1d8e2d56331888fb54152ef4378921fb9665175f638dd
6
+ metadata.gz: 56f28498cd0c3b525d726c58d3adff333b592cc4c06c77937d440cf81732b18908b124020e94ff70735eb41e46e8685f311e8c233f47ae232554ca3a74da62e6
7
+ data.tar.gz: 1c321e688429643b47cd5ddd0c27dc13ec1fa758d6e2fe86984b94517b745b443ef2ef863b02c630193b751723e420604c3d820ddceee71f7a8c00926f1cd809
@@ -2,7 +2,7 @@ require 'options_hash'
2
2
 
3
3
  class OptionsHash::MethodObject
4
4
 
5
- VERSION = '0.0.1'
5
+ VERSION = '0.1.0'
6
6
 
7
7
  def self.inherited(subclass)
8
8
  subclass.send :extend, ClassMethods
@@ -31,17 +31,6 @@ class OptionsHash::MethodObject
31
31
  def optional *keys, &block
32
32
  options.optional *keys, &block
33
33
  end
34
-
35
- def options_reader *keys
36
- keys.each do |key|
37
- options.option?(key) or raise KeyError, "#{key} is not an option", caller(2)
38
- define_method(key){ self.options[key] }
39
- end
40
- end
41
-
42
- def option_readers!
43
- options_reader *options.keys
44
- end
45
34
  end
46
35
 
47
36
  module InstanceMethods
@@ -49,6 +38,15 @@ class OptionsHash::MethodObject
49
38
  @options = self.class.options.parse(options)
50
39
  end
51
40
  attr_reader :options
41
+
42
+ def method_missing method, *args, &block
43
+ return options[method] if options.keys.include?(method)
44
+ raise NoMethodError, "undefined method `#{method}'", caller(1)
45
+ end
46
+
47
+ def given? key
48
+ options.given? key
49
+ end
52
50
  end
53
51
 
54
52
  end
@@ -5,8 +5,6 @@ class CreatePerson < OptionsHash::MethodObject
5
5
  required :name
6
6
  optional :favorite_color, default: ->{ 'blue' }
7
7
 
8
- options_reader :name, :favorite_color
9
-
10
8
  def call
11
9
  options
12
10
  end
@@ -17,8 +15,6 @@ class CreateRobot < CreatePerson
17
15
 
18
16
  required :model_number
19
17
 
20
- option_readers!
21
-
22
18
  def call
23
19
  [name, favorite_color, model_number]
24
20
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: options_hash-method_object
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jared Grippe