Class: LucidComponent::AppStoreDefaults
- Inherits:
-
Object
- Object
- LucidComponent::AppStoreDefaults
show all
- Defined in:
- lib/isomorfeus_react/lucid_component/app_store_defaults.rb
Instance Method Summary
collapse
Constructor Details
#initialize(state, component_name) ⇒ AppStoreDefaults
3
4
5
6
7
8
9
10
|
# File 'lib/isomorfeus_react/lucid_component/app_store_defaults.rb', line 3
def initialize(state, component_name)
@state = state
if @state.isomorfeus_store
@state.isomorfeus_store.merge!(application_state: {})
else
@state.isomorfeus_store = { application_state: {}}
end
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(key, *args, &block) ⇒ Object
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/isomorfeus_react/lucid_component/app_store_defaults.rb', line 12
def method_missing(key, *args, &block)
if `args.length > 0`
key = key.chop if `key.endsWith('=')`
@state.isomorfeus_store[:application_state][key] = args[0]
current_state = Isomorfeus.store.get_state
if !(current_state[:application_state].key?(key))
Isomorfeus.store.dispatch(type: 'APPLICATION_STATE', name: key, value: args[0])
end
else
if @state.isomorfeus_store[:application_state].key?(key)
return @state.isomorfeus_store[:application_state][key]
end
end
nil
end
|
Instance Method Details
32
33
34
|
# File 'lib/isomorfeus_react/lucid_component/app_store_defaults.rb', line 32
def to_h
@state.isomorfeus_store[:application_state]
end
|