molar 0.1.0 → 0.1.1

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: 64364e74a1242e5e31acda34cdc36c986ec6d4b2
4
- data.tar.gz: cc83c2322e936e6a1e60aeb5539db49b39fae194
3
+ metadata.gz: 727374c7735eafb585fbbb898230c346ad40cdbc
4
+ data.tar.gz: 48d317e0a5bed678f61a5106907b35beca529480
5
5
  SHA512:
6
- metadata.gz: 3203840e7521100be050bcfbd0b9cd18e4084041031c9eb1fbbf5949e05c5b776630b846dfe7e6f05a5f3b70fa60346ecb6671e537edd2474d74106e4c83f111
7
- data.tar.gz: 5701f1d82e36a823cead2aa9a736c39367ac4fa20555556b7ac857f055054fc53d88647e6dd34e02799668e0d6be5a0e802bc270dcfaf5f9f31f9222295ca592
6
+ metadata.gz: 886f09bf3538715a37f944e4f23463bdf74fbffb51678b7080ecd5217d898e731a7ec7a8239a9a5be895e3409c69539a0d36b90c9e7d088e7d298c3e3ad1c070
7
+ data.tar.gz: 503a3d0571a617df6afab7d9a4f0f1f1c9ce231095d51f865423359dd8d2c90a3423799702f94550f57574170fbdfea84185247ad9a74cef244a293954bf9f6b
data/.gitignore CHANGED
@@ -7,3 +7,4 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
+ *.gem
File without changes
File without changes
data/CHANGELOG.md ADDED
@@ -0,0 +1,9 @@
1
+ # Change Log
2
+ All notable changes to this project will be documented in this file.
3
+ This project adheres to [Semantic Versioning](http://semvar.org/).
4
+
5
+ ## [0.1.1] - 2016-02-14
6
+ ### Changed
7
+ - Define getter and setter for an attribute whenever either is first called.
8
+ - Lots of method cleanup accompanies this change, yay!
9
+ - `.rspec` and `.rubocop.yml` were accidentally placed in `lib`, moved to top level.
data/lib/molar.rb CHANGED
@@ -33,55 +33,36 @@ module Molar
33
33
  private :attributes
34
34
 
35
35
  def method_missing(method, *args, &block)
36
- action = __attribute?(method) ? :__register : :__method_missing
37
- send(action, method, *args, &block)
36
+ __attribute?(method) ? __register_and_call(method, *args, &block) : super
38
37
  end
39
38
  end
40
39
  end
41
40
  private_class_method :included
42
41
 
43
- def __register(method, *args)
44
- if __setter?(method)
45
- attr = __attr_name(method)
46
- __add_setter(attr)
47
- send(method, *args)
48
- else
49
- __add_getter(method)
50
- send(method)
51
- end
52
- end
53
- private :__register
54
-
55
42
  def __attribute?(name)
56
43
  attributes.key?(__attr_name(name))
57
44
  end
58
45
  private :__attribute?
59
46
 
60
- def __setter?(method)
61
- __attribute?(method) && method.to_s.end_with?('=')
62
- end
63
- private :__setter?
64
-
65
- def __attribute(attribute)
66
- attributes[attribute]
47
+ def __register_and_call(method, *args, &block)
48
+ __register(method)
49
+ send(method, *args, &block)
67
50
  end
68
- private :__attribute
51
+ private :__register_and_call
69
52
 
70
- def __add_getter(attribute)
71
- singleton_class.instance_eval do
72
- define_method(attribute) { __attribute(attribute) }
73
- end
53
+ def __register(method)
54
+ attr_name = __attr_name(method)
55
+ __add_methods(attr_name)
74
56
  end
75
- private :__add_getter
57
+ private :__register
76
58
 
77
- def __add_setter(attribute)
59
+ def __add_methods(attribute)
78
60
  singleton_class.instance_eval do
79
- define_method("#{attribute}=") do |value|
80
- attributes[attribute] = value
81
- end
61
+ define_method(attribute) { attributes[attribute] }
62
+ define_method("#{attribute}=") { |val| attributes[attribute] = val }
82
63
  end
83
64
  end
84
- private :__add_setter
65
+ private :__add_methods
85
66
 
86
67
  def __attr_name(attribute)
87
68
  str_attr = attribute.to_s
data/lib/molar/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Molar
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: molar
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
  - Connor Jacobsen
@@ -102,15 +102,16 @@ extensions: []
102
102
  extra_rdoc_files: []
103
103
  files:
104
104
  - ".gitignore"
105
+ - ".rspec"
106
+ - ".rubocop.yml"
105
107
  - ".travis.yml"
108
+ - CHANGELOG.md
106
109
  - Gemfile
107
110
  - LICENSE
108
111
  - README.md
109
112
  - Rakefile
110
113
  - bin/console
111
114
  - bin/setup
112
- - lib/.rspec
113
- - lib/.rubocop.yml
114
115
  - lib/molar.rb
115
116
  - lib/molar/version.rb
116
117
  - molar.gemspec