Class: ActiveElement::DefaultController::JsonParams

Inherits:
Object
  • Object
show all
Defined in:
lib/active_element/default_controller/json_params.rb

Overview

Provides permitted parameters for fields generated from a JSON schema file.

Instance Method Summary collapse

Constructor Details

#initialize(schema:) ⇒ JsonParams

Returns a new instance of JsonParams.



7
8
9
# File 'lib/active_element/default_controller/json_params.rb', line 7

def initialize(schema:)
  @base_schema = schema
end

Instance Method Details

#params(schema = base_schema) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/active_element/default_controller/json_params.rb', line 11

def params(schema = base_schema)
  return simple_object_field(schema) if simple_object_field?(schema)
  return simple_array_field(schema) if simple_array_field?(schema)
  return complex_array_field(schema) if complex_array_field?(schema)

  schema[:name]
end