Class: Sass::Environment

Inherits:
Object show all
Defined in:
lib/sass/environment.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent = nil) ⇒ Environment

Returns a new instance of Environment.



5
6
7
8
9
# File 'lib/sass/environment.rb', line 5

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

Instance Attribute Details

#parentObject (readonly)

Returns the value of attribute parent.



3
4
5
# File 'lib/sass/environment.rb', line 3

def parent
  @parent
end

Class Method Details

.inherited_hash(name) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/sass/environment.rb', line 11

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)
      if @parent && @parent.#{name}(name)
        @parent.set_#{name}(name, value)
      else
        @#{name}s[name] = value
      end
    end

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