https://github.com/annacrombie/kaicho
a resource manager
https://github.com/annacrombie/kaicho
resource-management ruby
Last synced: over 1 year ago
JSON representation
a resource manager
- Host: GitHub
- URL: https://github.com/annacrombie/kaicho
- Owner: annacrombie
- Created: 2018-10-02T16:39:10.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2019-04-06T14:47:00.000Z (about 7 years ago)
- Last Synced: 2025-03-22T21:29:11.380Z (over 1 year ago)
- Topics: resource-management, ruby
- Language: Ruby
- Size: 52.7 KB
- Stars: 0
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Kaicho
[](https://travis-ci.org/annacrombie/kaicho)
[](https://coveralls.io/github/annacrombie/kaicho?branch=master)
[](http://inch-ci.org/github/annacrombie/kaicho)
[](https://badge.fury.io/rb/kaicho)
Kaicho is the boss for your resources. It handles keeping everything up to
date.
```ruby
class Fruits
include Kaicho
def intialize
def_resource :apples, accessor: :both { @apples || 0 }
def_resource :oranges, accessor: :both { @oranges || 0 }
def_resource :total, depend: { apples: :fail, oranges: :fail } do
puts "computing total"
@apples + @oranges
end
end
end
f = Fruits.new
f.apples #=> 0
f.apples += 1 #=> 1
computing total
f.oranges = 10 #=> 10
computing total
f.total #=> 11
f.oranges = 2
computing total
f.total #=> 13
f.total #=> 13
```