Sha256: 16664d9f6dc4ea8e6c772f30102f045de52c6df9f91c3fc477475349785f53f2
Contents?: true
Size: 1.53 KB
Versions: 1
Compression:
Stored size: 1.53 KB
Contents
# Thread-safe class inheritable attributes [GitHub repository](https://github.com/Roman2K/class-inheritable-attributes). ## Installation $ gem install Roman2K-class-inheritable-attributes -s http://gems.github.com/ ## Features Allows for defining class-level attributes whose values are: * inherited by subclasses, * stored in a thread safe manner, * accessible via calls to `super`, * stored in a memory efficient manner (the registry shrinks itself on `nil` values). ## Example usage require 'class_inheritable_attributes' class Resource class_inheritable_attr_accessor :site, :timeout def self.timeout super || 10 end def self.timeout=(seconds) super(seconds.to_i) end end Resource.timeout # => 10 Resource.timeout = "5" Resource.timeout # => 5 class AccountingResource < Resource self.site = "http://account.example.com" end class Balance < AccountingResource end # Child's value defaults to parent's AccountingResource.site # => "http://account.example.com" Balance.site # => "http://account.example.com" # Child can set its own value Balance.site = "http://balance.account.example.com" AccountingResource.site # => "http://account.example.com" Balance.site # => "http://balance.account.example.com" ## Credits Written by [Roman Le NĂ©grate](http://roman.flucti.com) ([contact](mailto:roman.lenegrate@gmail.com)). Released under the MIT license: see the `LICENSE` file.
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
Roman2K-class-inheritable-attributes-0.1.1 | README.mdown |