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:



24
25
26
27
# File 'lib/grape/validations/params_scope.rb', line 24

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

Instance Attribute Details

#keyObject

Returns the value of attribute key.



19
20
21
# File 'lib/grape/validations/params_scope.rb', line 19

def key
  @key
end

#scopeObject

Returns the value of attribute scope.



19
20
21
# File 'lib/grape/validations/params_scope.rb', line 19

def scope
  @scope
end

Class Method Details

.attr_key(declared_param_attr) ⇒ Object



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

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



30
31
32
33
34
# File 'lib/grape/validations/params_scope.rb', line 30

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