Class | Hashery::OpenHash |
In: |
lib/hashery/open_hash.rb
|
Parent: | CRUDHash |
OpenHash is a Hash, but also supports open properties much like OpenStruct.
Only names that are name methods of Hash can be used as open slots. To open a slot for a name that would otherwise be a method, the method needs to be made private. The `open!` method can be used to handle this.
Examples
o = OpenHash.new o.open!(:send) o.send = 4
class | -> | object_class |
safe | [RW] | If safe is set to true, then public methods cannot be overriden by hash keys. |
Make specific Hash methods available for use that have previously opened.
methods - [Array<String,Symbol>] method names
Returns methods.
Open up a slot that that would normally be a Hash method.
The only methods that can‘t be opened are ones starting with `__`.
methods - [Array<String,Symbol>] method names
Returns Array of slot names that were opened.