Class: RVM::Functions::AssocSet
- Defined in:
- lib/rvm/functions/association/assoc_set.rb
Overview
The AssocSet function is used to set elements of a Association, it takes the Association as first argument, the key as second and the valuse as third.
It can also be called with two arguments, a key and a value if the :self variable is set and a Association - thus it is in object context of a Association.
Class Method Summary collapse
Methods inherited from Function
call, data_type, execargs, method_missing
Methods included from Plugin
#helper, #included, #plugin_host, #plugin_id, #register_for
Class Method Details
.execute(params, env) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/rvm/functions/association/assoc_set.rb', line 37 def execute params, env if params.length == 3 assoc = params.shift key = params.shift value = params.shift assoc[key] = value elsif params.length == 2 and (this = env.read_var_val(:self)).is_a?(RVM::Classes[:association]) key = params.shift value = params.shift this[key] = value else RVM::Classes[:error].new(1,"FUNCTION (#{self.class}) EXPECTS 3 or 2 ARGUMENTS BUT GOT #{params.length}") end end |
.signature ⇒ Object
52 53 54 |
# File 'lib/rvm/functions/association/assoc_set.rb', line 52 def signature [:any] end |