diff options
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | lib/hashie/extensions/structure.rb | 45 |
2 files changed, 1 insertions, 45 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 5dfc9e2..07e9599 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ ## Next Release +* Removed extra unused code - [@markiz](https://github.com/markiz). * Removed support for Ruby 1.8.7 - [@dblock](https://github.com/dblock). * Ruby style now enforced with Rubocop - [@dblock](https://github.com/dblock). * [#107](https://github.com/intridea/hashie/pull/107): Fixed excessive value conversions, poor performance of deep merge in Hashie::Mash - [@davemitchell](https://github.com/dblock), [@dblock](https://github.com/dblock). diff --git a/lib/hashie/extensions/structure.rb b/lib/hashie/extensions/structure.rb deleted file mode 100644 index 302499b..0000000 --- a/lib/hashie/extensions/structure.rb +++ /dev/null @@ -1,45 +0,0 @@ -module Hashie - module Extensions - # 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 - # - module Structure - def self.included(base) - base.extend ClassMethods - base.class_eval do - @permitted_keys = superclass.permitted_keys if superclass.respond_to?(:permitted_keys) - end - end - - module ClassMethods - attr_reader :permitted_keys - - def key(key, options = {}) - (@permitted_keys ||= []) << key - - if options[:default] - (@default_values ||= {})[key] = options.delete(:default) - end - - permitted_keys - end - end - end - end -end |