Module: ParamsReady::Helpers::ParameterDefinerClassMethods

Defined in:
lib/params_ready/helpers/parameter_definer_class_methods.rb

Instance Method Summary collapse

Instance Method Details

#all_parametersObject



29
30
31
32
33
34
35
36
# File 'lib/params_ready/helpers/parameter_definer_class_methods.rb', line 29

def all_parameters
  parameters = if superclass.respond_to? :all_parameters
    superclass.all_parameters
  else
    {}
  end
  parameters.merge(params_ready_storage.parameters)
end

#all_relationsObject



20
21
22
23
24
25
26
27
# File 'lib/params_ready/helpers/parameter_definer_class_methods.rb', line 20

def all_relations
  relations = if superclass.respond_to? :all_relations
    superclass.all_relations
  else
    {}
  end
  relations.merge(params_ready_storage.relations)
end

#define_parameter(type, *args, **opts, &block) ⇒ Object



14
15
16
17
18
# File 'lib/params_ready/helpers/parameter_definer_class_methods.rb', line 14

def define_parameter(type, *args, **opts, &block)
  full_name = "define_#{type}"
  parameter = Builder.send(full_name, *args, **opts, &block)
  params_ready_storage.add_parameter parameter
end

#define_relation(*args, **opts, &block) ⇒ Object



7
8
9
10
11
12
# File 'lib/params_ready/helpers/parameter_definer_class_methods.rb', line 7

def define_relation(*args, **opts, &block)
  wrapper = ParamsReady::Helpers::RelationBuilderWrapper.new self, *args, **opts
  wrapper.instance_eval(&block) unless block.nil?
  relation = wrapper.build
  params_ready_storage.add_relation relation
end