Class: LucidComponent::InstanceStoreProxy
- Inherits:
-
Object
- Object
- LucidComponent::InstanceStoreProxy
show all
- Defined in:
- lib/isomorfeus_react/lucid_component/instance_store_proxy.rb
Instance Method Summary
collapse
Constructor Details
Returns a new instance of InstanceStoreProxy.
3
4
5
6
7
|
# File 'lib/isomorfeus_react/lucid_component/instance_store_proxy.rb', line 3
def initialize(component_instance)
@native = component_instance.to_n
@component_instance = component_instance
@component_object_id = component_instance.object_id.to_s
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(key, *args, &block) ⇒ Object
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/isomorfeus_react/lucid_component/instance_store_proxy.rb', line 17
def method_missing(key, *args, &block)
if `args.length > 0`
action = { type: 'INSTANCE_STATE', object_id: @component_object_id, name: (`key.endsWith('=')` ? key.chop : key), value: args[0] }
Isomorfeus.store.collect_and_defer_dispatch(action)
else
if @native.JS[:props].JS[:store]
if @native.JS[:props].JS[:store].JS[:instance_state] &&
@native.JS[:props].JS[:store].JS[:instance_state].JS[@component_object_id] &&
@native.JS[:props].JS[:store].JS[:instance_state].JS[@component_object_id].JS.hasOwnProperty(key)
return @native.JS[:props].JS[:store].JS[:instance_state].JS[@component_object_id].JS[key]
end
else
a_state = Isomorfeus.store.get_state
if a_state.key?(:instance_state) && a_state[:instance_state].key?(key)
return a_state[:instance_state][key]
end
end
return nil
end
end
|
Instance Method Details
9
10
11
|
# File 'lib/isomorfeus_react/lucid_component/instance_store_proxy.rb', line 9
def [](key)
method_missing(key)
end
|
#[]=(key, value) ⇒ Object
13
14
15
|
# File 'lib/isomorfeus_react/lucid_component/instance_store_proxy.rb', line 13
def []=(key, value)
method_missing(key, value)
end
|