Class: RubyLint::Template::Scope

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby-lint/template/scope.rb

Overview

Class used for storing variables for an ERB template without polluting the namespace of the code that uses the template.

Instance Method Summary collapse

Constructor Details

#initialize(variables = {}) ⇒ Scope

Returns a new instance of Scope

Parameters:

  • variables (Hash) (defaults to: {})


11
12
13
14
15
# File 'lib/ruby-lint/template/scope.rb', line 11

def initialize(variables = {})
  variables.each do |name, value|
    instance_variable_set("@#{name}", value)
  end
end

Instance Method Details

#get_bindingBinding

Returns:

  • (Binding)


32
33
34
# File 'lib/ruby-lint/template/scope.rb', line 32

def get_binding
  return binding # #binding() is a private method.
end

#return_instance?(type, name) ⇒ Boolean

Returns true if the method’s definition should return an instance of the container.

Parameters:

  • type (Symbol)
  • name (Symbol)

Returns:

  • (Boolean)


24
25
26
27
# File 'lib/ruby-lint/template/scope.rb', line 24

def return_instance?(type, name)
  return (type == :method && name == :new) ||
    (type == :instance_method && name == :initialize)
end