Class: Fluid::FluidVar

Inherits:
Var
  • Object
show all
Defined in:
lib/fluid.rb

Overview

FluidVars are those accessed via “Fluid.varname”. This subclass contains the code for adding those getters and setters.

Instance Attribute Summary

Attributes inherited from Var

#name, #original_name

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Var

global?, #initialize, #pop_binding, #push_binding

Constructor Details

This class inherits a constructor from Fluid::Var

Class Method Details

.build(*args) ⇒ Object

:nodoc:



104
105
106
# File 'lib/fluid.rb', line 104

def FluidVar.build(*args)
  new(*args)  # No subclasses to build specially.
end

Instance Method Details

#assert_acceptable_nameObject



120
121
122
123
124
125
126
127
128
# File 'lib/fluid.rb', line 120

def assert_acceptable_name
  unless name.to_s =~ /^[a-z_]\w*$/
    raise NameError, "'#{original_name}' is not a good fluid variable name. It can't be used as a method name."
  end

  if Fluid.methods.include?(name.to_s)
    raise NameError, "'#{original_name}' cannot be a fluid variable. It's already a method of Fluid's."
  end
end

#createObject



108
109
110
111
112
# File 'lib/fluid.rb', line 108

def create
  super
  Fluid.create_getter(name)
  Fluid.create_setter(name)
end

#destroyObject



114
115
116
117
118
# File 'lib/fluid.rb', line 114

def destroy
  super
  Fluid.delete_getter(name)
  Fluid.delete_setter(name)
end