Module: RVM::ActsAsRVMType::ActsAsRVMTypeInstanceMethods

Defined in:
lib/rvm/acts_as_rvm_type.rb

Overview

This module hods the instance methods for classes that are supposed to act as a rVM type.

It includes register_variable and register_function to help setting up the class quickly.

Instance Method Summary collapse

Instance Method Details

#object_functionsObject

Returns the hash of variables for to be used only internally by the ActsAsRVMTypeSingeltonMethods#variables function to set up the details.



152
153
154
# File 'lib/rvm/acts_as_rvm_type.rb', line 152

def object_functions
  @functions
end

#object_variablesObject

Returns the hash of variables for to be used only internally by the ActsAsRVMTypeSingeltonMethods#variables function to set up the details.



146
147
148
# File 'lib/rvm/acts_as_rvm_type.rb', line 146

def object_variables
  @variables
end

#register_function(name, published_as = name) ⇒ Object

This registers a variable for the rVM interface, it allows the scripts to read and write them. If writable is set this will be a read only variable. It alls an be published to rVM under a different name, by passing published_as.



131
132
133
134
135
136
137
138
139
140
141
142
# File 'lib/rvm/acts_as_rvm_type.rb', line 131

def register_function name, published_as = name
  @functions[published_as.to_s] = Class.new(RVM::Functions::Function) do @name = name; end
  class << @functions[published_as.to_s]
    def execute params, env
      env.read_var_val(:self).send(@name, *params)
    end
    
    def signature
      [:any] 
    end
  end
end

#register_variable(name, writable = true, published_as = name) ⇒ Object

This registers a variable for the rVM interface, it allows the scripts to read and write them. If writable is set this will be a read only variable. It alls an be published to rVM under a different name, by passing published_as.



123
124
125
# File 'lib/rvm/acts_as_rvm_type.rb', line 123

def register_variable name, writable = true, published_as = name
  @variables[published_as.to_s] = [name.to_sym, writable]
end