module Compass::Configuration::Inheritance::ClassMethods

Public Instance Methods

chained_method(method) click to toggle source
# File lib/compass/configuration/inheritance.rb, line 162
def chained_method(method)
  line = __LINE__ + 1
  class_eval %Q{
    alias_method :_chained_#{method}, method
    def #{method}(*args, &block)
      _chained_#{method}(*args, &block)
      if inherited_data
        inherited_data.#{method}(*args, &block)
      end
    end
  }, __FILE__, line
end
inherited_accessor(*attributes) click to toggle source
# File lib/compass/configuration/inheritance.rb, line 59
def inherited_accessor(*attributes)
  inherited_reader(*attributes)
  inherited_writer(*attributes)
end
inherited_array(*attributes) click to toggle source
# File lib/compass/configuration/inheritance.rb, line 112
def inherited_array(*attributes)
  options = attributes.last.is_a?(Hash) ? attributes.pop : {}
  inherited_reader(*attributes)
  inherited_writer(*attributes)
  attributes.each do |attr|
    line = __LINE__ + 1
    class_eval %Q{
      def #{attr}                                          # def sprite_load_paths
        ArrayProxy.new(self, #{attr.inspect})              #   ArrayProxy.new(self, :sprite_load_paths)
      end                                                  # end
      def #{attr}=(value)                                  # def sprite_load_paths=(value)
        @set_attributes ||= {}                             #   @set_attributes ||= {}
        @set_attributes[#{attr.inspect}] = true            #   @set_attributes[:sprite_load_paths] = true
        @#{attr} = Array(value)                            #   @sprite_load_paths = Array(value)
        @added_to_#{attr} = []                             #   @added_to_sprite_load_paths = []
        @removed_from_#{attr} = []                         #   @removed_from_sprite_load_paths = []
      end                                                  # end
      def read_inherited_#{attr}_array                     # def read_inherited_sprite_load_paths_array
        value = if inherited_data                          #   value = if inherited_data
          if #{!!options[:clobbers]} && #{attr}_set?
            Array(@#{attr})                                #     Array(@#{attr})
          else
            Array(@#{attr}) + inherited_data.read_inherited_#{attr}_array  #      inherited_data.read_inherited_sprite_load_paths_array + Array(@sprite_load_paths)
          end
        elsif #{attr}_set?                                 #   elsif sprite_load_paths_set?
          Array(@#{attr})                                  #     Array(@#{attr})
        else                                               #   else
          top_level.default_for(#{attr.inspect}) || []     #     top_level.default_for(:sprite_load_paths) || []
        end                                                #   end
        value -= Array(@removed_from_#{attr})              #   value -= Array(@removed_from_sprite_load_paths)
        Array(@added_to_#{attr}) + value                   #   Array(@added_to_sprite_load_paths) + value
      end                                                  # end
      def add_to_#{attr}(v)                                # def add_to_sprite_load_paths(v)
        if #{attr}_set?                                    #   if sprite_load_paths_set?
          raw_#{attr} << v                                 #     raw_sprite_load_paths << v
        else                                               #   else
          (@added_to_#{attr} ||= []) << v                  #     (@added_to_sprite_load_paths ||= []) << v
        end                                                #   end
      end                                                  # end
      def remove_from_#{attr}(v)                           # def remove_from_sprite_load_paths(v)
        if #{attr}_set?                                    #   if sprite_load_paths_set?
          raw_#{attr}.reject!{|e| e == v}                  #     raw_sprite_load_path.reject!{|e| e == v}s
        else                                               #   else
          (@removed_from_#{attr} ||= []) << v              #     (@removed_from_sprite_load_paths ||= []) << v
        end                                                #   end
      end                                                  # end
    }, __FILE__, line
  end
end
inherited_reader(*attributes) click to toggle source

Defines the default reader to be an #inherited_reader that will look at the inherited_data for its value when not set. The inherited reader calls to a raw reader that acts like a normal attribute reader but prefixes the attribute name with “raw_”.

# File lib/compass/configuration/inheritance.rb, line 42
def inherited_reader(*attributes)
  attributes.each do |attribute|
    line = __LINE__ + 1
    class_eval %Q{
      def raw_#{attribute}                         # def raw_css_dir
        @#{attribute}                              #   @css_dir
      end                                          # end
      def #{attribute}_without_default             # def css_dir_without_default
        read_without_default(#{attribute.inspect}) #  read_without_default(:css_dir)
      end                                          # end
      def #{attribute}                             # def css_dir
        read(#{attribute.inspect})                 #  read(:css_dir)
      end                                          # end
    }, __FILE__, line
  end
end
inherited_writer(*attributes) click to toggle source
# File lib/compass/configuration/inheritance.rb, line 18
def inherited_writer(*attributes)
  attributes.each do |attribute|
    line = __LINE__ + 1
    class_eval %Q{
      def #{attribute}=(value)                        # def css_dir=(value)
        @set_attributes ||= {}                        #   @set_attributes ||= {}
        @set_attributes[#{attribute.inspect}] = true  #   @set_attributes[:css_dir] = true
        @#{attribute} = value                         #   @css_dir = value
      end                                             # end

      def unset_#{attribute}!                         # def unset_css_dir!
        unset!(#{attribute.inspect})                  #   unset!(:css_dir)
      end                                             # end

      def #{attribute}_set?                           # def css_dir_set?
        set?(#{attribute.inspect})                    #   set?(:css_dir)
      end                                             # end
    }, __FILE__, line
  end
end