activeyaml 1.0.1 → 1.2.0
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
|
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
|
@@ -3,9 +3,8 @@
|
|
3
3
|
require_relative 'yaml_hash'
|
4
4
|
|
5
5
|
module ActiveYaml
|
6
|
-
#
|
7
|
-
|
8
|
-
module MethodRedirection
|
6
|
+
# no doc
|
7
|
+
module MethodMapper
|
9
8
|
def method_missing(method, *args, &)
|
10
9
|
value = yaml_data[method.to_s]
|
11
10
|
|
data/lib/active_yaml/version.rb
CHANGED
@@ -9,6 +9,8 @@ module ActiveYaml
|
|
9
9
|
@hash = hash || {}
|
10
10
|
end
|
11
11
|
|
12
|
+
# The main logic of this class is implemented in this method.
|
13
|
+
# Allows you to filter method calls and redirect them to a hash by key
|
12
14
|
def method_missing(method, *args, &)
|
13
15
|
value = hash[method.to_s]
|
14
16
|
|
@@ -21,6 +23,10 @@ module ActiveYaml
|
|
21
23
|
end
|
22
24
|
end
|
23
25
|
|
26
|
+
def respond_to_missing?(method, include_private = false)
|
27
|
+
hash.key?(method.to_s) || super
|
28
|
+
end
|
29
|
+
|
24
30
|
def inspect
|
25
31
|
hash
|
26
32
|
end
|
@@ -28,9 +34,5 @@ module ActiveYaml
|
|
28
34
|
def to_s
|
29
35
|
hash.to_s
|
30
36
|
end
|
31
|
-
|
32
|
-
def respond_to_missing?(method, include_private = false)
|
33
|
-
hash.key?(method.to_s) || super
|
34
|
-
end
|
35
37
|
end
|
36
38
|
end
|
data/lib/active_yaml.rb
CHANGED
@@ -1,16 +1,17 @@
|
|
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
|
9
10
|
extend FactoryHash
|
10
11
|
|
11
12
|
# Base class to inherit from to create models
|
12
|
-
class
|
13
|
-
include
|
13
|
+
class BaseModel
|
14
|
+
include MethodMapper
|
14
15
|
|
15
16
|
def self.yaml(file_path)
|
16
17
|
define_method(:yaml_data) do
|
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.0
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kirill Leonov
|
@@ -31,8 +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
|
35
|
-
- lib/active_yaml/
|
36
|
+
- lib/active_yaml/method_mapper.rb
|
36
37
|
- lib/active_yaml/parser.rb
|
37
38
|
- lib/active_yaml/version.rb
|
38
39
|
- lib/active_yaml/yaml_hash.rb
|