lib/lotus/routing/resource/options.rb in lotus-router-0.1.0 vs lib/lotus/routing/resource/options.rb in lotus-router-0.1.1

- old
+ new

@@ -6,11 +6,11 @@ # @api private # @since 0.1.0 # # @see Lotus::Router#resource # @see Lotus::Router#resources - class Options < Hash + class Options # @api private # @since 0.1.0 attr_reader :actions # Initialize the options for: @@ -38,10 +38,35 @@ def initialize(actions, options = {}) only = Array(options.delete(:only) || actions) except = Array(options.delete(:except)) @actions = ( actions & only ) - except - merge! options + @options = options + end + + # Return the option for the given key + # + # @param key [Symbol] the key that should be searched + # + # @return [Object,nil] returns the object associated to the given key + # or nil, if missing. + # + # @api private + # @since 0.1.1 + def [](key) + @options[key] + end + + # Merge the current options with the given hash, without mutating self. + # + # @param hash [Hash] the hash to be merged + # + # @return [Hash] the result of the merging operation + # + # @api private + # @since 0.1.1 + def merge(hash) + @options.merge(hash) end end end end end