Class: Grape::Validations::ParamsScope::Attr

Inherits:
Object
  • Object
show all
Defined in:
lib/grape/validations/params_scope.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key, scope) ⇒ Attr

Open up a new ParamsScope::Attr

Parameters:



22
23
24
25
# File 'lib/grape/validations/params_scope.rb', line 22

def initialize(key, scope)
  @key = key
  @scope = scope
end

Instance Attribute Details

#keyObject

Returns the value of attribute key.



17
18
19
# File 'lib/grape/validations/params_scope.rb', line 17

def key
  @key
end

#scopeObject

Returns the value of attribute scope.



17
18
19
# File 'lib/grape/validations/params_scope.rb', line 17

def scope
  @scope
end

Class Method Details

.attr_key(declared_param_attr) ⇒ Object



34
35
36
37
38
39
40
41
42
# File 'lib/grape/validations/params_scope.rb', line 34

def self.attr_key(declared_param_attr)
  return attr_key(declared_param_attr.key) if declared_param_attr.is_a?(self)

  if declared_param_attr.is_a?(Hash)
    declared_param_attr.transform_values { |value| attrs_keys(value) }
  else
    declared_param_attr
  end
end

.attrs_keys(declared_params) ⇒ Object



28
29
30
31
32
# File 'lib/grape/validations/params_scope.rb', line 28

def self.attrs_keys(declared_params)
  declared_params.map do |declared_param_attr|
    attr_key(declared_param_attr)
  end
end