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:



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

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

Instance Attribute Details

#keyObject

Returns the value of attribute key.



14
15
16
# File 'lib/grape/validations/params_scope.rb', line 14

def key
  @key
end

#scopeObject

Returns the value of attribute scope.



14
15
16
# File 'lib/grape/validations/params_scope.rb', line 14

def scope
  @scope
end

Class Method Details

.attr_key(declared_param_attr) ⇒ Object



31
32
33
34
35
36
37
38
39
# File 'lib/grape/validations/params_scope.rb', line 31

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



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

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