contextuable 0.3.0 → 0.4.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f078d3e26b5f6a206f595db13edf2eeed2149f00
4
- data.tar.gz: 2bffb3821243b8b7617d4b782a8cb6dadfc3f519
3
+ metadata.gz: c4632e806422ee43f145bf4dd94711f60a078ee0
4
+ data.tar.gz: f1a18b9b8e4e4f652ab96da04108308a85991438
5
5
  SHA512:
6
- metadata.gz: 95857c57a2be144c38be622a911b71f5e22e3d92c643a2d37961fbc9fe3e2640457ae602441d4c1790942139739a5902b1ca9f7e4a484115aa15a7ba607959fb
7
- data.tar.gz: 1f4a390b7c957a89044b03ecb5509060c863111f774dd86c5ce63c7e6bae6ee2efe9b92d8c9f4146c31efd7db1a1b44e1a470c73a4dbf8de8d78e6dd92e0bc96
6
+ metadata.gz: bb9f81bffa242b136fd49a4e9021409b6d24e44e6287475a3ec517c5db0ae2b2a7d01f49142832197fe09185421293bdb8a68eb3e640395f1c096945d4a7f44f
7
+ data.tar.gz: cc5edeaec80e11bdd8a05c702f6f952747da6d9594e8bbfd1b4c45cd59f03b9d3ee9eb1e16ecc9d7176284f2baa497bf715f84bff17b6e7d932f26e99750065d
data/README.md CHANGED
@@ -66,18 +66,26 @@ i.hotel_name
66
66
  i.phone_number_provided?
67
67
  # => false
68
68
  i.not_permitted
69
- # => nil
69
+ # => NoMethodError: undefined method
70
70
  ```
71
71
 
72
72
  ### Building better Structs
73
73
 
74
74
  **no_method_error**
75
+ ```ruby
76
+ class Example < Contextuable
77
+ no_method_error false
78
+ end
79
+
80
+ Example.new(foo: :bar).hello # => nil
81
+ ```
82
+
75
83
  ```ruby
76
84
  class Example < Contextuable
77
85
  no_method_error
78
86
  end
79
87
 
80
- Example.new(foo: :bar).hello # => Error: NoMethodError
88
+ Example.new(foo: :bar).hello # => => NoMethodError: undefined method
81
89
  ```
82
90
 
83
91
  **required**
@@ -1,5 +1,5 @@
1
1
  class Contextuable
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  autoload :ClassMethods, 'contextuable/class_methods'
4
4
  autoload :InstanceMethods, 'contextuable/instance_methods'
5
5
 
@@ -37,9 +37,10 @@ class Contextuable
37
37
  def method_missing(name, *args, &block)
38
38
  if name =~ /\A\w+=\z/
39
39
  set_attribute_macro(name, *args, &block)
40
+ elsif out = provided_macro(name)
41
+ out[:out]
40
42
  else
41
- out = provided_macro(name)
42
- out ? out[:out] : nil
43
+ super
43
44
  end
44
45
  end
45
46
 
@@ -17,7 +17,10 @@ class Contextuable
17
17
  else
18
18
  out = provided_macro(name)
19
19
  return out[:out] if out
20
- raise NoMethodError if _no_method_error
20
+ if _no_method_error
21
+ super
22
+ # raise NoMethodError, "Method not found for #{self.class}: `#{name}`"
23
+ end
21
24
  end
22
25
  end
23
26
 
@@ -56,7 +59,7 @@ class Contextuable
56
59
  end
57
60
 
58
61
  def _no_method_error
59
- !_get_config[:no_method_error] == false
62
+ _get_config[:no_method_error].nil? ? true : _get_config[:no_method_error]
60
63
  end
61
64
 
62
65
  def _defaults
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: contextuable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Artur Pañach
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-04-05 00:00:00.000000000 Z
11
+ date: 2016-05-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -93,7 +93,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
93
93
  version: '0'
94
94
  requirements: []
95
95
  rubyforge_project:
96
- rubygems_version: 2.4.6
96
+ rubygems_version: 2.6.3
97
97
  signing_key:
98
98
  specification_version: 4
99
99
  summary: Structs with steroids.