Sha256: f5cbe1c1c019d20e00463923b56aa98142e85f507b76d1e25fee4dc356eb3268

Contents?: true

Size: 1.36 KB

Versions: 26

Compression:

Stored size: 1.36 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),
            required_relationships: %i(item_type)
          ).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

26 entries across 26 versions & 1 rubygems

Version Path
dato-0.2.4 lib/dato/site/repo/menu_item.rb
dato-0.1.31 lib/dato/site/repo/menu_item.rb
dato-0.1.30 lib/dato/site/repo/menu_item.rb
dato-0.1.29 lib/dato/site/repo/menu_item.rb
dato-0.1.28 lib/dato/site/repo/menu_item.rb
dato-0.1.27 lib/dato/site/repo/menu_item.rb
dato-0.1.26 lib/dato/site/repo/menu_item.rb
dato-0.1.25 lib/dato/site/repo/menu_item.rb
dato-0.1.24 lib/dato/site/repo/menu_item.rb
dato-0.1.23 lib/dato/site/repo/menu_item.rb
dato-0.1.22 lib/dato/site/repo/menu_item.rb
dato-0.1.21 lib/dato/site/repo/menu_item.rb
dato-0.1.20 lib/dato/site/repo/menu_item.rb
dato-0.1.19 lib/dato/site/repo/menu_item.rb
dato-0.1.18 lib/dato/site/repo/menu_item.rb
dato-0.1.17 lib/dato/site/repo/menu_item.rb
dato-0.1.16 lib/dato/site/repo/menu_item.rb
dato-0.1.15 lib/dato/site/repo/menu_item.rb
dato-0.1.14 lib/dato/site/repo/menu_item.rb
dato-0.1.13 lib/dato/site/repo/menu_item.rb