Sha256: cf3928a37252c3081af8546ac8901e067952cf384de8cb2d955c0f4d984d9e24
Contents?: true
Size: 1.04 KB
Versions: 71
Compression:
Stored size: 1.04 KB
Contents
module LucidComponent class AppStoreDefaults 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 def method_missing(key, *args, &block) if `args.length > 0` # set initial class state 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 # get class state # check if we have a component local state value if @state.isomorfeus_store[:application_state].key?(key) return @state.isomorfeus_store[:application_state][key] end end nil end def to_h @state.isomorfeus_store[:application_state] end end end
Version data entries
71 entries across 71 versions & 1 rubygems