Class: TRMNL::API::Models::Recipe

Inherits:
Data
  • Object
show all
Defined in:
lib/trmnl/api/models/recipe.rb

Overview

Models the payload of the API response.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data

Returns:

  • (Object)

    the current value of data



9
10
11
# File 'lib/trmnl/api/models/recipe.rb', line 9

def data
  @data
end

#metaObject (readonly)

Returns the value of attribute meta

Returns:

  • (Object)

    the current value of meta



9
10
11
# File 'lib/trmnl/api/models/recipe.rb', line 9

def meta
  @meta
end

Class Method Details

.empty(meta: Recipes::Meta.new) ⇒ Object



10
# File 'lib/trmnl/api/models/recipe.rb', line 10

def self.empty(meta: Recipes::Meta.new) = new(data: Core::EMPTY_ARRAY, meta:)

.for(**attributes) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/trmnl/api/models/recipe.rb', line 12

def self.for(**attributes)
  meta = attributes.slice :from,
                          :to,
                          :current_page,
                          :per_page,
                          :total,
                          :prev_page_url,
                          :next_page_url

  data = attributes[:data].map { Recipes::Data.for(**it) }

  new meta: Recipes::Meta[**meta], data:
end