isomorfeus-data 2.5.5 → 22.9.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,113 +0,0 @@
1
- class LucidQueryResult
2
- attr_reader :key
3
-
4
- def [](accessor_name)
5
- self.send(accessor_name.to_sym)
6
- end
7
-
8
- def sid
9
- [@class_name, @key]
10
- end
11
-
12
- def sid_s
13
- "[#{@class_name}|#{@key}]"
14
- end
15
-
16
- if RUBY_ENGINE == 'opal'
17
- def initialize(key: nil, result_set: nil, _loading: false)
18
- @class_name = 'LucidQueryResult'
19
- @key = key ? key.to_s : self.object_id.to_s
20
- @result_set = result_set
21
- end
22
-
23
- def _load_from_store!
24
- @result_set = nil
25
- end
26
-
27
- def loaded?
28
- Redux.fetch_by_path(:data_state, @class_name, @key) ? true : false
29
- end
30
-
31
- def key?(k)
32
- if @result_set
33
- @result_set.key?(k)
34
- else
35
- stored_results = Redux.fetch_by_path(:data_state, @class_name, @key)
36
- return false unless stored_results
37
- `Object.hasOwnProperty(stored_results, k)`
38
- end
39
- end
40
- alias has_key? key?
41
-
42
- def method_missing(accessor_name, *args, &block)
43
- sid_or_array = if @result_set
44
- @result_set[accessor_name]
45
- else
46
- stored_results = Redux.fetch_by_path(:data_state, @class_name, @key)
47
- stored_results.JS[accessor_name] if stored_results
48
- end
49
- return nil unless sid_or_array
50
- if stored_results.JS['_is_array_']
51
- sid_or_array.map { |sid| Isomorfeus.instance_from_sid(sid) }
52
- else
53
- Isomorfeus.instance_from_sid(sid_or_array)
54
- end
55
- end
56
- else
57
- def initialize(key: nil, result_set: nil)
58
- @class_name = 'LucidQueryResult'
59
- @key = key ? key.to_s : self.object_id.to_s
60
- @result_set = result_set.nil? ? {} : result_set
61
- @result_set.transform_keys!(&:to_sym)
62
- end
63
-
64
- def loaded?
65
- @result_set.any?
66
- end
67
-
68
- def key?(k)
69
- @result_set.key?(k)
70
- end
71
- alias has_key? key?
72
-
73
- def method_missing(accessor_name, *args, &block)
74
- Isomorfeus.raise_error(message: "#{@class_name}: no such thing '#{accessor_name}' in the results!") unless @result_set.key?(accessor_name)
75
- @result_set[accessor_name]
76
- end
77
-
78
- def to_transport
79
- sids_hash = {}
80
- @result_set.each do |key, value_or_array|
81
- if value_or_array.class == Array
82
- sids_hash[key.to_s] = value_or_array.map(&:sid)
83
- sids_hash[:_is_array_] = true
84
- else
85
- sids_hash[key.to_s] = value_or_array.nil? ? nil : value_or_array.sid
86
- end
87
- end
88
- { @class_name => { @key => sids_hash }}
89
- end
90
-
91
- def included_items_to_transport
92
- data_hash = {}
93
- @result_set.each_value do |value|
94
- if value.class == Array
95
- value.each do |v|
96
- data_hash.deep_merge!(v.to_transport)
97
- if v.respond_to?(:included_items_to_transport)
98
- data_hash.deep_merge!(v.included_items_to_transport)
99
- end
100
- end
101
- else
102
- unless value.nil?
103
- data_hash.deep_merge!(value.to_transport)
104
- if value.respond_to?(:included_items_to_transport)
105
- data_hash.deep_merge!(value.included_items_to_transport)
106
- end
107
- end
108
- end
109
- end
110
- data_hash
111
- end
112
- end
113
- end
data/opal/iso_uri.rb DELETED
@@ -1,29 +0,0 @@
1
- require "uri/common"
2
- require "uri/generic"
3
-
4
- module URI
5
- @@schemes = {}
6
-
7
- class InvalidURIError < Exception
8
- end
9
-
10
- def self.parse(url)
11
- # scheme://conn_data/path?query#hash
12
- match = url.match(%r[(\w+)://([^/]+)([^\?]+)(\?[^\#]+)?(\#.*)?])
13
-
14
- _, scheme, connection_data, path, query, fragment = match.to_a
15
-
16
- connection_data = connection_data.split(/@/)
17
- userinfo = connection_data.size > 1 ? connection_data.first : nil
18
- host, port = connection_data.last.split(/:/)
19
-
20
- port = port.to_i
21
- query = query[1..-1] if query
22
-
23
- registry = opaque = nil
24
-
25
- Generic.new(scheme, userinfo, host, port,
26
- registry, path, opaque, query,
27
- fragment)
28
- end
29
- end
data/opal/uri/common.rb DELETED
@@ -1,18 +0,0 @@
1
- module Kernel
2
-
3
- #
4
- # Returns +uri+ converted to a URI object.
5
- #
6
- def URI(uri)
7
- if uri.is_a?(URI::Generic)
8
- uri
9
- elsif uri = String.try_convert(uri)
10
- URI.parse(uri)
11
- else
12
- raise ArgumentError,
13
- "bad argument (expected URI object or URI string)"
14
- end
15
- end
16
- module_function :URI
17
- end
18
-
data/opal/uri/generic.rb DELETED
@@ -1,47 +0,0 @@
1
- module URI
2
- class Generic
3
- attr_reader :scheme, :userinfo, :user, :password, :host, :port, :path,
4
- :query, :fragment, :opaque, :registry
5
-
6
- #
7
- # An Array of the available components for URI::Generic
8
- #
9
- COMPONENT = [
10
- :scheme,
11
- :userinfo, :host, :port, :registry,
12
- :path, :opaque,
13
- :query,
14
- :fragment
15
- ]
16
-
17
- def initialize(scheme,
18
- userinfo, host, port, registry,
19
- path, opaque,
20
- query,
21
- fragment,
22
- parser = nil,
23
- arg_check = false)
24
- @scheme = scheme
25
- @userinfo = userinfo
26
- @host = host
27
- @port = port
28
- @path = path
29
- @query = query
30
- @fragment = fragment
31
- @user, @password = userinfo.split(/:/) if userinfo
32
- end
33
-
34
- def ==(other)
35
- self.class == other.class &&
36
- component_ary == other.component_ary
37
- end
38
-
39
- protected
40
-
41
- def component_ary
42
- self.class::COMPONENT.collect do |x|
43
- self.send(x)
44
- end
45
- end
46
- end
47
- end