Class: ROM::HTTP::Dataset::ResponseTransformers::Schemad

Inherits:
Object
  • Object
show all
Defined in:
lib/rom/http/dataset/response_transformers/schemad.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(schema) ⇒ Schemad

Returns a new instance of Schemad.



10
11
12
# File 'lib/rom/http/dataset/response_transformers/schemad.rb', line 10

def initialize(schema)
  @schema = schema
end

Instance Attribute Details

#schemaObject (readonly)

Returns the value of attribute schema.



8
9
10
# File 'lib/rom/http/dataset/response_transformers/schemad.rb', line 8

def schema
  @schema
end

Instance Method Details

#call(response, dataset) ⇒ Object



14
15
16
17
18
# File 'lib/rom/http/dataset/response_transformers/schemad.rb', line 14

def call(response, dataset)
  t(:map_array,
    t(:accept_keys, projections(dataset.projections)) >> ->(tuple) { schema.apply(tuple) }
   ).call(response)
end