Sha256: 9291150f5c87e365ca1a16ef91d315589766a16c49e3fb84802070aafdc2e72e

Contents?: true

Size: 769 Bytes

Versions: 2

Compression:

Stored size: 769 Bytes

Contents

require "kanji/type"

module Types
  class <%= config[:class_name] %> < Kanji::Type
    name "<%= config[:class_name] %>"
    description "Replace this description with something useful"

  <% config[:attributes].each do |attribute| -%>
    attribute :<%= attribute[0] %>, <%= config[:lookup_type].(attribute[1]) %>, "Replace this description"
  <% end -%>

    register :repo, <%= config[:application_class] %>::Container["repos.<%= config[:pluralized_type_name] %>"]

    create do |object, arguments, context|
      resolve(:repo).create(arguments.to_h)
    end

    update do |object, arguments, context|
      resolve(:repo).update(arguments.to_h)
    end

    destroy do |object, arguments, context|
      resolve(:repo).destroy(arguments[:id])
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
kanji-web-0.2.0 lib/kanji/templates/app/types/type.rb.tt
kanji-web-0.1.0 lib/kanji/templates/app/types/type.rb.tt