pendant
pendant
pendant is a small utility of accessor for Crystal.
This library is added hash-like accessor into your class.
Installation
Add it to Projectfile
deps do
github "MakeNowJust/pendant"
end
Usage
require "pendant"
class Accessory
# define properties and initializer
property name, owner
def initialize(@name, @owner); end
# include pendant module
# it defines `Accessory#[]`, `Accessory#[]?`, `Accessory#[]=` and
# `Accessory#keys` automatically.
include Pendant::Property
end
# create a new accessory
pendant = Accessory.new("pendant", "Alice")
# it can access via `[]` method
puts pendant[:name]
puts pendant["owner"]
Development
$ crystal spec spec/spec.cr
Contributing
- Fork it ( https://github.com/MakeNowJust/pendant/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
Contributors
- MakeNowJust TSUYUSATO Kitsune - creator, maintainer
Repository
pendant
Owner
Statistic
- 1
- 0
- 0
- 0
- 0
- over 9 years ago
- July 29, 2015
License
MIT License
Links
Synced at
Sun, 24 Nov 2024 10:11:04 GMT
Languages