Class: Sass::ReadOnlyEnvironment
- Inherits:
-
BaseEnvironment
- Object
- BaseEnvironment
- Sass::ReadOnlyEnvironment
- Defined in:
- lib/sass/environment.rb
Overview
A read-only wrapper for a lexical environment for SassScript.
Instance Attribute Summary
Attributes inherited from BaseEnvironment
Instance Method Summary collapse
-
#caller ⇒ ReadOnlyEnvironment
The read-only environment of the caller of this environment's mixin or function.
-
#content ⇒ [Array<Sass::Tree::Node>, ReadOnlyEnvironment]?
The content passed to this environment.
-
#initialize(parent = nil, options = nil) ⇒ ReadOnlyEnvironment
constructor
A new instance of ReadOnlyEnvironment.
Methods inherited from BaseEnvironment
#global?, #global_env, inherited_hash_accessor, inherited_hash_reader, inherited_hash_writer, #stack
Constructor Details
#initialize(parent = nil, options = nil) ⇒ ReadOnlyEnvironment
Returns a new instance of ReadOnlyEnvironment.
178 179 180 181 |
# File 'lib/sass/environment.rb', line 178
def initialize(parent = nil, options = nil)
super
@content_cached = nil
end
|
Instance Method Details
#caller ⇒ ReadOnlyEnvironment
The read-only environment of the caller of this environment's mixin or function.
186 187 188 189 190 |
# File 'lib/sass/environment.rb', line 186
def caller
return @caller if @caller
env = super
@caller ||= env.is_a?(ReadOnlyEnvironment) ? env : ReadOnlyEnvironment.new(env, env.options)
end
|
#content ⇒ [Array<Sass::Tree::Node>, ReadOnlyEnvironment]?
The content passed to this environment. If the content's environment isn't already read-only, it's made read-only.
200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 |
# File 'lib/sass/environment.rb', line 200
def content
# Return the cached content from a previous invocation if any
return @content if @content_cached
# get the content with a read-write environment from the superclass
read_write_content = super
if read_write_content
tree, env = read_write_content
# make the content's environment read-only
if env && !env.is_a?(ReadOnlyEnvironment)
env = ReadOnlyEnvironment.new(env, env.options)
end
@content_cached = true
@content = [tree, env]
else
@content_cached = true
@content = nil
end
end
|