Class: AppKernel::FunctionDefinition
- Inherits:
-
Object
- Object
- AppKernel::FunctionDefinition
- Defined in:
- lib/appkernel/function.rb
Defined Under Namespace
Instance Attribute Summary collapse
-
#impl ⇒ Object
readonly
Returns the value of attribute impl.
-
#mod ⇒ Object
readonly
Returns the value of attribute mod.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#validation ⇒ Object
readonly
Returns the value of attribute validation.
Instance Method Summary collapse
- #execute(&impl) ⇒ Object
- #indexed_options ⇒ Object
-
#initialize(name, mod, definition) ⇒ FunctionDefinition
constructor
A new instance of FunctionDefinition.
- #option(name, params = {}) ⇒ Object
- #to_s ⇒ Object
- #validate(&checks) ⇒ Object
Constructor Details
#initialize(name, mod, definition) ⇒ FunctionDefinition
Returns a new instance of FunctionDefinition.
134 135 136 137 138 139 140 141 |
# File 'lib/appkernel/function.rb', line 134 def initialize(name, mod, definition) @name = name @mod = mod @options = {} @impl = lambda {} @validation = ::AppKernel::Validation::Validator.new(self) self.instance_eval &definition end |
Instance Attribute Details
#impl ⇒ Object (readonly)
Returns the value of attribute impl.
132 133 134 |
# File 'lib/appkernel/function.rb', line 132 def impl @impl end |
#mod ⇒ Object (readonly)
Returns the value of attribute mod.
132 133 134 |
# File 'lib/appkernel/function.rb', line 132 def mod @mod end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
132 133 134 |
# File 'lib/appkernel/function.rb', line 132 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
132 133 134 |
# File 'lib/appkernel/function.rb', line 132 def @options end |
#validation ⇒ Object (readonly)
Returns the value of attribute validation.
132 133 134 |
# File 'lib/appkernel/function.rb', line 132 def validation @validation end |
Instance Method Details
#execute(&impl) ⇒ Object
152 153 154 |
# File 'lib/appkernel/function.rb', line 152 def execute(&impl) @impl = impl end |
#indexed_options ⇒ Object
148 149 150 |
# File 'lib/appkernel/function.rb', line 148 def @options.values.select {|o| o.index}.sort_by {|a| a.index} end |
#option(name, params = {}) ⇒ Object
143 144 145 146 |
# File 'lib/appkernel/function.rb', line 143 def option(name, params = {}) name = name.to_sym @options[name] = Option.new(name, params) end |
#to_s ⇒ Object
160 161 162 |
# File 'lib/appkernel/function.rb', line 160 def to_s "#{@name}()" end |
#validate(&checks) ⇒ Object
156 157 158 |
# File 'lib/appkernel/function.rb', line 156 def validate(&checks) @validation = AppKernel::Validation::Validator.new(self, &checks) end |