Sha256: cdb9fe1bc79a3fa76936ab80a50ffa7bce56817473355fbe76794ee2bd524e76

Contents?: true

Size: 1.08 KB

Versions: 17

Compression:

Stored size: 1.08 KB

Contents

module Sass
  class Environment
    attr_reader :parent
    attr_writer :options

    def initialize(parent = nil)
      @vars = {}
      @mixins = {}
      @parent = parent

      set_var("important", Script::String.new("!important")) unless @parent
    end

    def options
      @options || (parent && parent.options) || {}
    end

    def self.inherited_hash(name)
      class_eval <<RUBY, __FILE__, __LINE__ + 1
        def #{name}(name)
          @#{name}s[name] || @parent && @parent.#{name}(name)
        end

        def set_#{name}(name, value)
          @#{name}s[name] = value unless try_set_#{name}(name, value)
        end

        def try_set_#{name}(name, value)
          if @#{name}s.include?(name)
            @#{name}s[name] = value
            true
          elsif @parent
            @parent.try_set_#{name}(name, value)
          else
            false
          end
        end
        protected :try_set_#{name}

        def set_local_#{name}(name, value)
          @#{name}s[name] = value
        end
RUBY
    end
    inherited_hash :var
    inherited_hash :mixin
  end
end

Version data entries

17 entries across 17 versions & 2 rubygems

Version Path
gohanlonllc-haml-2.1.0.20080513000000 lib/sass/environment.rb
gohanlonllc-haml-2.1.0 lib/sass/environment.rb
haml-edge-2.1.10 lib/sass/environment.rb
haml-edge-2.1.11 lib/sass/environment.rb
haml-edge-2.1.12 lib/sass/environment.rb
haml-edge-2.1.18 lib/sass/environment.rb
haml-edge-2.1.19 lib/sass/environment.rb
haml-edge-2.1.20 lib/sass/environment.rb
haml-edge-2.1.21 lib/sass/environment.rb
haml-edge-2.1.17 lib/sass/environment.rb
haml-edge-2.1.13 lib/sass/environment.rb
haml-edge-2.1.14 lib/sass/environment.rb
haml-edge-2.1.15 lib/sass/environment.rb
haml-edge-2.1.16 lib/sass/environment.rb
haml-edge-2.1.8 lib/sass/environment.rb
haml-edge-2.1.7 lib/sass/environment.rb
haml-edge-2.1.9 lib/sass/environment.rb