activeyaml 1.1.1 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/active_yaml/class_methods.rb +17 -0
- data/lib/active_yaml/method_mapper.rb +24 -0
- data/lib/active_yaml/version.rb +1 -1
- data/lib/active_yaml.rb +4 -17
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2d6f31a30be9442d2006d3a021c8c67e094cd85fe4836b64772126011e3c30dd
|
4
|
+
data.tar.gz: 36e100c38e94324625d7497660710b008fd02425d23b482b027ebe544920766f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ec1821333bd0ea118fa3bd0c9e46316557513272c9f012b5ba878b91f8bcf27801eb31ec4dd731b8465e2280dff5856387c08d3df0af7974a1dd4b6fe94dee20
|
7
|
+
data.tar.gz: 70b1d65e75e4f7ae1c3246e7dedd3ff098e5ba59daac803686d725448b2ad3d4c850934c0bd85838b524ca7f0fa60d29b570c8e714761df8625784749fcf25a0
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'method_mapper'
|
4
|
+
require_relative 'parser'
|
5
|
+
|
6
|
+
module ActiveYaml
|
7
|
+
# no doc
|
8
|
+
module ClassMethods
|
9
|
+
include MethodMapper
|
10
|
+
|
11
|
+
def yaml(file_path)
|
12
|
+
define_singleton_method(:yaml_data) do
|
13
|
+
@yaml_data = Parser.parse(file_path)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'yaml_hash'
|
4
|
+
|
5
|
+
module ActiveYaml
|
6
|
+
# no doc
|
7
|
+
module MethodMapper
|
8
|
+
def method_missing(method, *args, &)
|
9
|
+
value = yaml_data[method.to_s]
|
10
|
+
|
11
|
+
if value
|
12
|
+
return value unless value.is_a?(Hash)
|
13
|
+
|
14
|
+
YamlHash.new(value)
|
15
|
+
else
|
16
|
+
super
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def respond_to_missing?(method, include_private = false)
|
21
|
+
yaml_data[method.to_s] || super
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/active_yaml/version.rb
CHANGED
data/lib/active_yaml.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative 'active_yaml/parser'
|
4
|
-
require_relative 'active_yaml/
|
4
|
+
require_relative 'active_yaml/method_mapper'
|
5
5
|
require_relative 'active_yaml/factory_hash'
|
6
|
+
require_relative 'active_yaml/class_methods'
|
6
7
|
|
7
8
|
# The main module from which work with gem begins
|
8
9
|
module ActiveYaml
|
@@ -10,26 +11,12 @@ module ActiveYaml
|
|
10
11
|
|
11
12
|
# Base class to inherit from to create models
|
12
13
|
class BaseModel
|
14
|
+
include MethodMapper
|
15
|
+
|
13
16
|
def self.yaml(file_path)
|
14
17
|
define_method(:yaml_data) do
|
15
18
|
@yaml_data = Parser.parse(file_path)
|
16
19
|
end
|
17
20
|
end
|
18
|
-
|
19
|
-
def method_missing(method, *args, &)
|
20
|
-
value = yaml_data[method.to_s]
|
21
|
-
|
22
|
-
if value
|
23
|
-
return value unless value.is_a?(Hash)
|
24
|
-
|
25
|
-
YamlHash.new(value)
|
26
|
-
else
|
27
|
-
super
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
def respond_to_missing?(method, include_private = false)
|
32
|
-
yaml_data[method.to_s] || super
|
33
|
-
end
|
34
21
|
end
|
35
22
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activeyaml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kirill Leonov
|
@@ -31,7 +31,9 @@ extensions: []
|
|
31
31
|
extra_rdoc_files: []
|
32
32
|
files:
|
33
33
|
- lib/active_yaml.rb
|
34
|
+
- lib/active_yaml/class_methods.rb
|
34
35
|
- lib/active_yaml/factory_hash.rb
|
36
|
+
- lib/active_yaml/method_mapper.rb
|
35
37
|
- lib/active_yaml/parser.rb
|
36
38
|
- lib/active_yaml/version.rb
|
37
39
|
- lib/active_yaml/yaml_hash.rb
|