method_man 3.0.0 → 3.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/method_object.rb +0 -45
- data/lib/method_object/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b53cee278d7e41a29dccd2ca0219b34d112d4ac7bd1a070662d23a1c29dde5f3
|
4
|
+
data.tar.gz: 483d234c24b309e7ad44391f9aa5cd20626d48182da9dae32857abb618b33629
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6033ad21000327166dd5cfc3601a649fd51cc54db074e83de454fd999bfae106f7bb5e535896c1bdd0d8c8581b3872b81a7babb6e517db0a8f56bbfee1a74696
|
7
|
+
data.tar.gz: 33b950b76bc8657b58214e068275ff2f6497536bdb5443a9a853df35caf74076b71ac1774ed1ab5554caac4dc859bb6ad2d54bad971c68874385beba20a92c10
|
data/lib/method_object.rb
CHANGED
@@ -124,49 +124,4 @@ class MethodObject < SimpleDelegator
|
|
124
124
|
"#{attribute}_"
|
125
125
|
end
|
126
126
|
end
|
127
|
-
|
128
|
-
# Dynamically defines custom attr_readers and initializer.
|
129
|
-
class Setup < SimpleDelegator
|
130
|
-
def self.call(attributes:, subclass:)
|
131
|
-
new(attributes, subclass).call
|
132
|
-
end
|
133
|
-
|
134
|
-
attr_accessor(:attributes)
|
135
|
-
|
136
|
-
def initialize(attributes, subclass)
|
137
|
-
self.attributes = attributes
|
138
|
-
super(subclass)
|
139
|
-
end
|
140
|
-
|
141
|
-
def call
|
142
|
-
define_attr_readers
|
143
|
-
define_initializer
|
144
|
-
end
|
145
|
-
|
146
|
-
private
|
147
|
-
|
148
|
-
def define_attr_readers
|
149
|
-
__getobj__.send(:attr_reader, *attributes)
|
150
|
-
end
|
151
|
-
|
152
|
-
def define_initializer
|
153
|
-
class_eval(<<-RUBY, __FILE__, __LINE__ + 1)
|
154
|
-
def initialize(#{required_keyword_args_string})
|
155
|
-
#{assignments}
|
156
|
-
end
|
157
|
-
RUBY
|
158
|
-
end
|
159
|
-
|
160
|
-
def required_keyword_args_string
|
161
|
-
attributes.map { |arg| "#{arg}:" }.join(', ')
|
162
|
-
end
|
163
|
-
|
164
|
-
def assignments
|
165
|
-
attributes.map { |attribute| "@#{attribute} = #{attribute}\n" }.join
|
166
|
-
end
|
167
|
-
end
|
168
|
-
|
169
|
-
def respond_to_missing?(*args)
|
170
|
-
super || __getobj__.respond_to?(*args)
|
171
|
-
end
|
172
127
|
end
|