lazy_record 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 +4 -4
- data/lib/lazy_record/methods.rb +20 -13
- data/lib/lazy_record/validations.rb +1 -1
- data/lib/lazy_record/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2a600da5b0f7578c40fca42e349acfdd8ead86f6
|
4
|
+
data.tar.gz: 39fdf3dd67b33c91235b7d18a067a55ecac89370
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cb2bbded1a40899dcdeedb83369810d4a7724fcd1b8debe0ace25549d5afb1a5927f5fcbe8c85877bfa17373afcf96db3cb144f036ec35032db677155a13d0d8
|
7
|
+
data.tar.gz: 02b008aa58f14d93b5d5e0f4e28c064826f795b6e47403918bff4f62a7bf827440de54a4035e9e4ec2a0fda3bc9aa6674576c1e2a7d2a8ac9a01336defd431ca
|
data/lib/lazy_record/methods.rb
CHANGED
@@ -14,21 +14,28 @@ class LazyRecord
|
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
-
def lr_method(method_name, *
|
18
|
-
mod
|
19
|
-
|
20
|
-
|
21
|
-
|
17
|
+
def lr_method(method_name, *method_args, method)
|
18
|
+
mod = get_or_set_and_include_mod(METHODS_MODULE_NAME)
|
19
|
+
method_args = method_args.map(&:to_s).join(', ')
|
20
|
+
|
22
21
|
if method.respond_to?(:call)
|
23
|
-
mod
|
24
|
-
send(:define_method, method_name, &method)
|
25
|
-
end
|
22
|
+
make_method_from_proc(mod, method_name, method)
|
26
23
|
else
|
27
|
-
mod
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
24
|
+
make_method_from_string(mod, method_name, method_args, method)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def make_method_from_proc(mod, method_name, proc)
|
29
|
+
mod.module_eval do
|
30
|
+
send(:define_method, method_name, &proc)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def make_method_from_string(mod, method_name, method_args, method)
|
35
|
+
mod.module_eval do
|
36
|
+
define_method(method_name) do |*params|
|
37
|
+
block = eval("lambda { |#{method_args}| #{method} }")
|
38
|
+
block.call(*params)
|
32
39
|
end
|
33
40
|
end
|
34
41
|
end
|
data/lib/lazy_record/version.rb
CHANGED