This repository has been archived by the owner. It is now read-only.

Estate

Simple predictable state manager

Estate 📂

Simple predictable state manager inspired by reworm

Installation

Add this to your application's shard.yml:

dependencies:
  estate:
    github: stepanvanzuriak/estate

Usage

Get state

require "estate"

state = Estate.create({name: "Steve", age: 19})

puts state.get({"name"}) # "Steve"
puts state.get({"name", "age"}) # {"Steve", 19}

Change state

require "estate"

state = Estate.create({bugs: 12, features: 13})

state.set { |prev| {features: prev["features"] + 1, bugs: prev["bugs"] + 10} }
puts state.get # {bugs: 22, features: 14}

Don't repeat yourself with select

require "estate"

state = Estate.create({name: "Jhon", status: "king", age: 21})

status = state.select({"status"})

puts status.call # "king"
puts status.call # "king"

extra_age = state.select { | state | state["age"] + 2 }

puts extra_age.call # 23
puts extra_age.call # 23

state.set { |prev| {age: prev["age"] + 1} }

puts extra_age.call # 24

Contributing

  1. Fork it (https://github.com/your-github-user/estate/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

Repository

Estate

Owner
Statistic
  • 1
  • 1
  • 0
  • 0
  • 0
  • about 6 years ago
  • August 24, 2018
License

MIT License

Links
Synced at

Mon, 25 Nov 2024 06:32:16 GMT

Languages