Sha256: 9215e0213b010c4d3a4bb7e641eebc0aee68410caa8441563f15b1abfa904751
Contents?: true
Size: 1.29 KB
Versions: 5
Compression:
Stored size: 1.29 KB
Contents
Attribrutal ============ Lazily coerced attributes ##Usage: class MoreSpeed include Attribrutal::Model attribute :harder attribute :better attribute :faster attribute :stronger end ##With coercion: class MoreSpeed include Attribrutal::Model attribute :harder, Coercion::Integer attribute :better, Coercion::String attribute :faster, Coercion::Boolean attribute :stronger, MyAwesomeCoercion end ##With defaults: class MoreSpeed include Attribrutal::Model attribute :harder, Coercion::Integer, default: 10 attribute :better, Coercion::String, default: "better" attribute :faster, Coercion::Boolean, default: true attribute :stronger, MyAwesomeCoercion end ##Introspection `MoreSpeed.attributes` return a hash of attribute names and their types ##Assignment `MoreSpeed.new harder: 30, better: "much"` ##Getting at raw (uncoerced) attributes `MoreSpeed.new.raw_attributes` ##Getting at coerced attributes `MoreSpeed.new.attributes` ##Coercers Implement your own, they should provide a class method `coerce` which takes two arguments; a value and a default and return the value coerced or the default, its all up to the coercer. You can implement any kind of additional meta information on the type.
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
attribrutal-0.0.12 | README.md |
attribrutal-0.0.10 | README.md |
attribrutal-0.0.6 | README.md |
attribrutal-0.0.5 | README.md |
attribrutal-0.0.4 | README.md |