Module: Pastore::Params::ClassMethods

Defined in:
lib/pastore/params.rb

Overview

Implement Pastore::Params class methods

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#_pastore_paramsObject

Returns the value of attribute _pastore_params.



34
35
36
# File 'lib/pastore/params.rb', line 34

def _pastore_params
  @_pastore_params
end

Instance Method Details

#invalid_params_status(status) ⇒ Object



44
45
46
# File 'lib/pastore/params.rb', line 44

def invalid_params_status(status)
  pastore_params.response_status = status
end

#method_added(name, *args, &block) ⇒ Object



60
61
62
63
# File 'lib/pastore/params.rb', line 60

def method_added(name, *args, &block)
  pastore_params.save_for(name)
  super
end

#on_invalid_params(&block) ⇒ Object



40
41
42
# File 'lib/pastore/params.rb', line 40

def on_invalid_params(&block)
  pastore_params.invalid_params_cbk = block
end

#param(name, **options) ⇒ Object



48
49
50
# File 'lib/pastore/params.rb', line 48

def param(name, **options)
  pastore_params.add(name, **options)
end

#pastore_paramsObject



36
37
38
# File 'lib/pastore/params.rb', line 36

def pastore_params
  self._pastore_params ||= Settings.new(superclass)
end

#scope(*keys, &block) ⇒ Object



52
53
54
55
56
57
58
# File 'lib/pastore/params.rb', line 52

def scope(*keys, &block)
  return unless block_given?

  pastore_params.set_scope(*keys)
  block.call
  pastore_params.reset_scope!
end