Module: ParamsReady::Helpers::ParameterUserClassMethods

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

Instance Method Summary collapse

Instance Method Details

#action_interface(*action_names, **opts, &block) ⇒ Object



28
29
30
31
32
# File 'lib/params_ready/helpers/parameter_user_class_methods.rb', line 28

def action_interface(*action_names, **opts, &block)
  definer = InterfaceDefiner.new(action_names, self)

  definer.define(**opts, &block)
end

#params_ready_optionObject



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/params_ready/helpers/parameter_user_class_methods.rb', line 6

def params_ready_option
  @params_ready_option ||= begin
    if superclass.respond_to? :params_ready_option
      # This works on assumption that superclass
      # definition doesn't change during execution
      superclass.params_ready_option.dup
    else
      ParamsReady::Helpers::Options.new
    end
  end
end

#use_parameter(name, rule = :all) ⇒ Object



18
19
20
21
# File 'lib/params_ready/helpers/parameter_user_class_methods.rb', line 18

def use_parameter(name, rule = :all)
  parameter = parameter_definition name
  params_ready_option.use_parameter parameter, rule
end

#use_relation(name, rule = :all) ⇒ Object



23
24
25
26
# File 'lib/params_ready/helpers/parameter_user_class_methods.rb', line 23

def use_relation(name, rule = :all)
  relation = relation_definition name
  params_ready_option.use_relation relation, rule
end