lib/bindata/params.rb
# Definition method for creating a method that maintains a collection
# of parameters.  This is used for creating collections of mandatory,
# optional, default etc parameters.  The parameters for a class will
# include the parameters of its ancestors.
Definition method for creating a method that maintains a collection
of parameters.  This is used for creating collections of mandatory,
optional, default etc parameters.  The parameters for a class will
include the parameters of its ancestors.
Definition method for creating a method that maintains a collection of parameters . This is used for creating collections of mandatory optional default etc parameters . The parameters for a class will include the parameters of its ancestors .
def define_x_parameters(name, empty, &block) 
      full_name_singular = "#{name.to_s}_parameter"
      full_name_plural = "#{name.to_s}_parameters"
      sym = full_name_plural.to_sym
      iv = "@#{full_name_plural}".to_sym
      body = Proc.new do |*args|
        unless instance_variable_defined?(iv)
          ancestor = ancestors[1..-1].find { |a| a.respond_to?(sym) }
          val = ancestor.nil? ? empty : ancestor.send(sym).dup
          instance_variable_set(iv, val)
        end
        if not args.empty?
          block.call(instance_variable_get(iv), args)
        end
        instance_variable_get(iv)
      end
      define_method(sym, body)
      alias_method(full_name_singular.to_sym, sym)
    end
def define_x_parameters ( name , empty , & block ) full_name_singular = "#{name.to_s}_parameter" full_name_plural = "#{name.to_s}_parameters" sym = full_name_plural . to_sym iv = "@#{full_name_plural}" . to_sym body = Proc . new do | * args | unless instance_variable_defined? ( iv ) ancestor = ancestors [ 1 .. - 1 ] . find { | a | a . respond_to? ( sym ) } val = ancestor . nil? ? empty : ancestor . send ( sym ) . dup instance_variable_set ( iv , val ) end if not args . empty? block . call ( instance_variable_get ( iv ) , args ) end instance_variable_get ( iv ) end define_method ( sym , body ) alias_method ( full_name_singular . to_sym , sym ) end
Definition method for creating a method that maintains a collection
of parameters.
Definition method for creating a method that maintains a collection of parameters .
#:nodoc: # initialize collection to duplicate ancestor's collection # add new parameters to the collection # return collection
name
<not_specific>
empty
<not_specific>
block
<not_specific>