Sha256: 521ede2ae493bc3fa7d2e32de0ec3a06cc799415c84184943765b1e728171012

Contents?: true

Size: 1.31 KB

Versions: 41

Compression:

Stored size: 1.31 KB

Contents

# frozen_string_literal: true
require 'dato/site/repo/base'

module Dato
  module Site
    module Repo
      class MenuItem < Base
        def create(resource_attributes)
          body = JsonApiSerializer.new(
            type: :menu_item,
            attributes: %i(label position),
            relationships: { item_type: { collection: false, type: :item_type }, parent: { collection: false, type: :menu_item } },
            required_attributes: %i(label position)
          ).serialize(resource_attributes)

          post_request '/menu-items', body
        end

        def update(menu_item_id, resource_attributes)
          body = JsonApiSerializer.new(
            type: :menu_item,
            attributes: %i(label position),
            relationships: { item_type: { collection: false, type: :item_type }, parent: { collection: false, type: :menu_item } },
            required_attributes: %i(label position)
          ).serialize(resource_attributes, menu_item_id)

          put_request "/menu-items/#{menu_item_id}", body
        end

        def all
          get_request '/menu-items'
        end

        def find(menu_item_id)
          get_request "/menu-items/#{menu_item_id}"
        end

        def destroy(menu_item_id)
          delete_request "/menu-items/#{menu_item_id}"
        end
      end
    end
  end
end

Version data entries

41 entries across 41 versions & 1 rubygems

Version Path
dato-0.5.1 lib/dato/site/repo/menu_item.rb
dato-0.5.0 lib/dato/site/repo/menu_item.rb
dato-0.4.3 lib/dato/site/repo/menu_item.rb
dato-0.4.2 lib/dato/site/repo/menu_item.rb
dato-0.4.1 lib/dato/site/repo/menu_item.rb
dato-0.4.0 lib/dato/site/repo/menu_item.rb
dato-0.3.31 lib/dato/site/repo/menu_item.rb
dato-0.4.0.pre lib/dato/site/repo/menu_item.rb
dato-0.3.30 lib/dato/site/repo/menu_item.rb
dato-0.3.29 lib/dato/site/repo/menu_item.rb
dato-0.3.28 lib/dato/site/repo/menu_item.rb
dato-0.3.27 lib/dato/site/repo/menu_item.rb
dato-0.3.26 lib/dato/site/repo/menu_item.rb
dato-0.3.25 lib/dato/site/repo/menu_item.rb
dato-0.3.24 lib/dato/site/repo/menu_item.rb
dato-0.3.23 lib/dato/site/repo/menu_item.rb
dato-0.3.22 lib/dato/site/repo/menu_item.rb
dato-0.3.21 lib/dato/site/repo/menu_item.rb
dato-0.3.20 lib/dato/site/repo/menu_item.rb
dato-0.3.19 lib/dato/site/repo/menu_item.rb