Module | Hashie::Extensions::Structure |
In: |
lib/hashie/extensions/structure.rb
|
The Structure extension provides facilities for declaring properties that a Hash can have. This provides for the creation of structures that still behave like hashes but do not allow setting non-allowed keys.
@example
class RestrictedHash < Hash include Hashie::Extensions::MergeInitializer include Hashie::Extensions::Structure key :first key :second, :default => 'foo' end h = RestrictedHash.new(:first => 1) h[:first] # => 1 h[:second] # => 'foo' h[:third] # => ArgumentError