Module: ActionParamsPermitter::Builders::Concerns::ResourceRequiring

Included in:
Main
Defined in:
lib/action_params_permitter/builders/concerns/resource_requiring.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.prepended(base) ⇒ Object



5
6
7
8
9
# File 'lib/action_params_permitter/builders/concerns/resource_requiring.rb', line 5

def self.prepended(base)
  base.instance_eval do
    attr_reader :is_required
  end
end

Instance Method Details

#initialize(*params) ⇒ Object



11
12
13
14
# File 'lib/action_params_permitter/builders/concerns/resource_requiring.rb', line 11

def initialize(*params)
  @is_required = false
  super(*params)
end

#resource(name, options = {}, &block) ⇒ Object



16
17
18
19
20
# File 'lib/action_params_permitter/builders/concerns/resource_requiring.rb', line 16

def resource(name, options = {}, &block)
  check_double_requiring(options)
  @is_required = true if options.fetch(:required, false)
  super
end