molar 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 +4 -4
- data/.gitignore +1 -0
- data/{lib/.rspec → .rspec} +0 -0
- data/{lib/.rubocop.yml → .rubocop.yml} +0 -0
- data/CHANGELOG.md +9 -0
- data/lib/molar.rb +13 -32
- data/lib/molar/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 727374c7735eafb585fbbb898230c346ad40cdbc
|
4
|
+
data.tar.gz: 48d317e0a5bed678f61a5106907b35beca529480
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 886f09bf3538715a37f944e4f23463bdf74fbffb51678b7080ecd5217d898e731a7ec7a8239a9a5be895e3409c69539a0d36b90c9e7d088e7d298c3e3ad1c070
|
7
|
+
data.tar.gz: 503a3d0571a617df6afab7d9a4f0f1f1c9ce231095d51f865423359dd8d2c90a3423799702f94550f57574170fbdfea84185247ad9a74cef244a293954bf9f6b
|
data/.gitignore
CHANGED
data/{lib/.rspec → .rspec}
RENAMED
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
|
-
|
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
|
61
|
-
|
62
|
-
|
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 :
|
51
|
+
private :__register_and_call
|
69
52
|
|
70
|
-
def
|
71
|
-
|
72
|
-
|
73
|
-
end
|
53
|
+
def __register(method)
|
54
|
+
attr_name = __attr_name(method)
|
55
|
+
__add_methods(attr_name)
|
74
56
|
end
|
75
|
-
private :
|
57
|
+
private :__register
|
76
58
|
|
77
|
-
def
|
59
|
+
def __add_methods(attribute)
|
78
60
|
singleton_class.instance_eval do
|
79
|
-
define_method(
|
80
|
-
|
81
|
-
end
|
61
|
+
define_method(attribute) { attributes[attribute] }
|
62
|
+
define_method("#{attribute}=") { |val| attributes[attribute] = val }
|
82
63
|
end
|
83
64
|
end
|
84
|
-
private :
|
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
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.
|
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
|