Class: Syphon::Schema::NestedField

Inherits:
Field
  • Object
show all
Defined in:
lib/syphon/schema.rb

Instance Attribute Summary collapse

Attributes inherited from Field

#expression, #name, #schema, #type

Instance Method Summary collapse

Methods inherited from Field

#multi?

Constructor Details

#initialize(schema, name, options = {}, &block) ⇒ NestedField

Returns a new instance of NestedField.



109
110
111
112
# File 'lib/syphon/schema.rb', line 109

def initialize(schema, name, options = {}, &block)
  super(schema, name, :nested, nil, options)
  @nested_schema = Schema.new(&block)
end

Instance Attribute Details

#nested_schemaObject (readonly)

Returns the value of attribute nested_schema.



114
115
116
# File 'lib/syphon/schema.rb', line 114

def nested_schema
  @nested_schema
end

Instance Method Details

#propertiesObject



116
117
118
# File 'lib/syphon/schema.rb', line 116

def properties
  super.merge(properties: nested_schema.properties)
end

#selectObject



120
121
122
# File 'lib/syphon/schema.rb', line 120

def select
  nested_schema.fields.map { |n, f| f.select(name) }.join(', ')
end