This repository has been archived by the owner on Dec 5, 2019. It is now read-only.
dominictarr/quick_attr
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
basic usage: require 'quick_attr'; class C extend QuickAttr quick_attr :name, :smell end #set attr by passing value c = C.new.name("bobaloba ding-dong").smell("fishy") #get attr by calling without args... puts c.name # bobaloba ding-dong puts c.smell # fishy also, if you want an attribute that defaults to a certain class, for example an array: class C quick_array :monkey_poems end c= C.new c.monkey_poems << "asdas sdfjg dfg alsdasdlfj sdlfkj sd" puts c.monkey_poems.inspect -> ["asdas sdfjg dfg alsdasdlfj sdlfkj sd"] you can also set it like before. c.monkey_poems(:a,:s,:d:,:f) puts c.monkey_poems.inspect -> [:a,:s,:d,:f] quick_hash is also like quick_array. quick_klass expects the first argument to be a class a creates attr which behaves like attr but defaults to klass i.e. class NewArray < Array; end quick_klass NewArray, :new_array code is at: http://github.com/dominictarr/quick_attr
About
No description, website, or topics provided.
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published