Class: RubyLint::Template::Scope
- Inherits:
-
Object
- Object
- RubyLint::Template::Scope
- 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
-
#get_binding ⇒ Binding
-
#initialize(variables = {}) ⇒ Scope
constructor
A new instance of Scope.
-
#return_instance?(type, name) ⇒ Boolean
Returns
true
if the method’s definition should return an instance of the container.
Constructor Details
#initialize(variables = {}) ⇒ Scope
Returns a new instance of Scope
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_binding ⇒ 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.
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 |