Class List Method List File List

# Class: Haml::Util::StaticConditionalContext

Inherits:
  Object
  - Object
  - Haml::Util::StaticConditionalContext
  show all
Defined in:
  lib/haml/util.rb

## Overview

The context in which the ERB for #def_static_method will be run.

## Instance Method Summary (collapse)

- - (StaticConditionalContext) initialize(set) constructor

  A new instance of StaticConditionalContext.

- - (Boolean) method_missing(name, *args, &block)

  Checks whether or not a variable is defined for this context.

## Constructor Details

### - (`StaticConditionalContext`) initialize(set)

Returns a new instance of StaticConditionalContext

Parameters:

- set (`#include?`) —

  The set of variables that are defined for this context.

    193
    194
    195

    # File 'lib/haml/util.rb', line 193

    def initialize(set)
      @set = set
    end

## Dynamic Method Handling

This class handles dynamic methods through the `method_missing` method

### - (`Boolean`) method_missing(name, *args, &block)

Checks whether or not a variable is defined for this context.

Parameters:

- name (`Symbol`) —

  The name of the variable

Returns:

- (`Boolean`)

    201
    202
    203
    204

    # File 'lib/haml/util.rb', line 201

    def method_missing(name, *args, &block)
      super unless args.empty? && block.nil?
      @set.include?(name)
    end