# File lib/compass/configuration/inheritance.rb, line 112 def any_attributes_set? @set_attributes && @set_attributes.size > 0 end
# File lib/compass/configuration/inheritance.rb, line 162 def chain instances = [self] instances << instances.last.inherited_data while instances.last.inherited_data instances end
# File lib/compass/configuration/inheritance.rb, line 168 def debug normalized_attrs = {} ATTRIBUTES.each do |prop| values = [] chain.each do |instance| values << { :raw => (instance.send("raw_#{prop}") rescue nil), :value => (instance.send("#{prop}_without_default") rescue nil), :default => (instance.send("default_#{prop}") rescue nil), :resolved => instance.send(prop) } end normalized_attrs[prop] = values end normalized_attrs end
# File lib/compass/configuration/inheritance.rb, line 116 def default_for(attribute) method = "default_#{attribute}".to_sym if respond_to?(method) send(method) end end
# File lib/compass/configuration/inheritance.rb, line 81 def inherit_from!(data) if self.inherited_data self.inherited_data.inherit_from!(data) else self.inherited_data = data end self end
# File lib/compass/configuration/inheritance.rb, line 144 def method_missing(meth, *args, &block) if inherited_data inherited_data.send(meth, *args, &block) else raise NoMethodError, meth.to_s end end
# File lib/compass/configuration/inheritance.rb, line 69 def on_top! self.set_top_level(self) end
Read a value that is either inherited or set on this instance, if we get to the bottom-most configuration instance, we ask for the default starting at the top level.
# File lib/compass/configuration/inheritance.rb, line 136 def read(attribute) if !(v = send("#{attribute}_without_default")).nil? v else top_level.default_for(attribute) end end
Read an explicitly set value that is either inherited or set on this instance
# File lib/compass/configuration/inheritance.rb, line 124 def read_without_default(attribute) if set?(attribute) send("raw_#{attribute}") elsif inherited_data.respond_to?("#{attribute}_without_default") inherited_data.send("#{attribute}_without_default") elsif inherited_data.respond_to?(attribute) inherited_data.send(attribute) end end
# File lib/compass/configuration/inheritance.rb, line 90 def reset_inheritance! self.inherited_data = nil end
# File lib/compass/configuration/inheritance.rb, line 152 def respond_to?(meth) if super true elsif inherited_data inherited_data.respond_to?(meth) else false end end
# File lib/compass/configuration/inheritance.rb, line 107 def set?(attribute) @set_attributes ||= {} @set_attributes[attribute] end
# File lib/compass/configuration/inheritance.rb, line 73 def set_top_level(new_top) self.top_level = new_top if self.inherited_data.respond_to?(:set_top_level) self.inherited_data.set_top_level(new_top) end end
# File lib/compass/configuration/inheritance.rb, line 100 def unset!(attribute) @set_attributes ||= {} send("#{attribute}=", nil) @set_attributes.delete(attribute) nil end
# File lib/compass/configuration/inheritance.rb, line 94 def with_defaults(data) inherit_from!(data) yield reset_inheritance! end