Class: RKit::Dsl::Base::Params
Instance Attribute Summary collapse
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#params_lambda ⇒ Object
readonly
Returns the value of attribute params_lambda.
Instance Method Summary collapse
-
#extract_local_variables(base) ⇒ Object
TODO: extract local variables may be an independant service of rkit.
- #extract_parameters(base, *args, &block) ⇒ Object
-
#initialize(params_lambda) ⇒ Params
constructor
A new instance of Params.
- #try_parameters(*args, &block) ⇒ Object
Constructor Details
#initialize(params_lambda) ⇒ Params
Returns a new instance of Params.
4 5 6 7 8 9 |
# File 'lib/r_kit/dsl/base/params.rb', line 4 def initialize params_lambda raise NoLambdaError unless params_lambda.lambda? @params_lambda = params_lambda @params = Hash.new{ |hash, key| hash[key] = params_struct.new } end |
Instance Attribute Details
#params ⇒ Object (readonly)
Returns the value of attribute params.
2 3 4 |
# File 'lib/r_kit/dsl/base/params.rb', line 2 def params @params end |
#params_lambda ⇒ Object (readonly)
Returns the value of attribute params_lambda.
2 3 4 |
# File 'lib/r_kit/dsl/base/params.rb', line 2 def params_lambda @params_lambda end |
Instance Method Details
#extract_local_variables(base) ⇒ Object
TODO: extract local variables may be an independant service of rkit
22 23 24 25 26 27 |
# File 'lib/r_kit/dsl/base/params.rb', line 22 def extract_local_variables base base.singleton_class.send :prepend, RKit::Dsl::Base::LocalParams base.persisting_binding.eval( @params[base].to_hash.map{ |name, value| "#{ name }=#{ value.inspect }" }.join(";") ) end |
#extract_parameters(base, *args, &block) ⇒ Object
16 17 18 |
# File 'lib/r_kit/dsl/base/params.rb', line 16 def extract_parameters base, *args, &block @params[base] = params_struct.new @params_lambda.extract_parameters(*args, &block) end |
#try_parameters(*args, &block) ⇒ Object
12 13 14 |
# File 'lib/r_kit/dsl/base/params.rb', line 12 def try_parameters *args, &block @params_lambda.call *args, &block end |