Module: Parametric::Params
- Defined in:
- lib/parametric/params.rb
Defined Under Namespace
Modules: DSL
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(base) ⇒ Object
13 14 15 16 |
# File 'lib/parametric/params.rb', line 13 def self.included(base) base.send(:attr_reader, :params) base.extend DSL end |
Instance Method Details
#available_params ⇒ Object
22 23 24 25 26 |
# File 'lib/parametric/params.rb', line 22 def available_params @available_params ||= params.each_with_object(ParamsHash.new) do |(k,v),memo| memo[k] = v if Utils.present?(v) end end |
#initialize(raw_params = {}) ⇒ Object
18 19 20 |
# File 'lib/parametric/params.rb', line 18 def initialize(raw_params = {}) @params = _reduce(raw_params) end |
#schema ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/parametric/params.rb', line 28 def schema @schema ||= params.each_with_object({}) do |(k,v),memo| memo[k] = { value: Utils.value(v), label: self.class._allowed_params[k][:label], multiple: !!self.class._allowed_params[k][:multiple] } memo[k][:match] = self.class._allowed_params[k][:match].to_s if self.class._allowed_params[k].has_key?(:match) memo[k][:options] = self.class._allowed_params[k][:options] if self.class._allowed_params[k].has_key?(:options) end end |