Created
November 24, 2016 13:32
-
-
Save selfup/e04020e61448c213921b658c8715ff7c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Rubux | |
attr_reader :state | |
def initialize(state = {}, actions = {}) | |
@state = state | |
@actions = actions | |
end | |
def dispatch(key, value) | |
return @state = @state.merge(@actions[key].(state, value)) if @actions[key] | |
raise 'no action with that key name is defined' | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment