https://github.com/bsedin/sequel-store
store_accessor functionality for sequel models
https://github.com/bsedin/sequel-store
sequel
Last synced: about 1 year ago
JSON representation
store_accessor functionality for sequel models
- Host: GitHub
- URL: https://github.com/bsedin/sequel-store
- Owner: bsedin
- License: mit
- Created: 2017-06-01T11:49:42.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-06-01T12:11:57.000Z (about 9 years ago)
- Last Synced: 2025-03-02T13:52:17.079Z (over 1 year ago)
- Topics: sequel
- Language: Ruby
- Homepage:
- Size: 2.93 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SequelStore
Tiny extension for Sequel to add store_accessor capabilities similar to ActiveRecord::Store: http://api.rubyonrails.org/classes/ActiveRecord/Store.html
## Installation
Add this line to your application's Gemfile:
```ruby
gem 'sequel-store'
```
And then add extension to Sequel:
```
Sequel.extension :store_accessor
```
Now define your accessors in `Sequel::Model` classes:
```
class Article < Sequel::Model(:articles)
store_accessor :metadata, :year, :rating, :views_count
def views_count
super || 0
end
end
```
```
article = Article.new
article.year #=> nil
article.year = 2017
article.year #=> 2017
article.views_count #=> 0
article.metadata #=> {"year"=>2017}
```
## Development
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
## Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/kressh/sequel-store.
## License
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).