lib/grape/util/inheritable_setting.rb in grape-0.16.2 vs lib/grape/util/inheritable_setting.rb in grape-0.17.0

- old
+ new

@@ -1,11 +1,12 @@ module Grape module Util # A branchable, inheritable settings object which can store both stackable # and inheritable values (see InheritableValues and StackableValues). class InheritableSetting - attr_accessor :route, :api_class, :namespace, :namespace_inheritable, :namespace_stackable + attr_accessor :route, :api_class, :namespace + attr_accessor :namespace_inheritable, :namespace_stackable, :namespace_reverse_stackable attr_accessor :parent, :point_in_time_copies # Retrieve global settings. def self.global @global ||= {} @@ -26,10 +27,11 @@ self.api_class = {} self.namespace = InheritableValues.new # only inheritable from a parent when # used with a mount, or should every API::Class be a separate namespace by default? self.namespace_inheritable = InheritableValues.new self.namespace_stackable = StackableValues.new + self.namespace_reverse_stackable = ReverseStackableValues.new self.point_in_time_copies = [] self.parent = nil end @@ -48,10 +50,11 @@ self.parent = parent namespace_inheritable.inherited_values = parent.namespace_inheritable namespace_stackable.inherited_values = parent.namespace_stackable + namespace_reverse_stackable.inherited_values = parent.namespace_reverse_stackable self.route = parent.route.merge(route) point_in_time_copies.map { |cloned_one| cloned_one.inherit_from parent } end @@ -65,10 +68,11 @@ new_setting.point_in_time_copies = [] new_setting.namespace = namespace.clone new_setting.namespace_inheritable = namespace_inheritable.clone new_setting.namespace_stackable = namespace_stackable.clone + new_setting.namespace_reverse_stackable = namespace_reverse_stackable.clone new_setting.route = route.clone new_setting.api_class = api_class new_setting.inherit_from(parent) end @@ -85,10 +89,11 @@ { global: global.clone, route: route.clone, namespace: namespace.to_hash, namespace_inheritable: namespace_inheritable.to_hash, - namespace_stackable: namespace_stackable.to_hash + namespace_stackable: namespace_stackable.to_hash, + namespace_reverse_stackable: namespace_reverse_stackable.to_hash } end end end end