Sha256: d4c55c7801d1094e35482158677e617cdc2bc51c90b58248ab306e496ff8a6d5

Contents?: true

Size: 765 Bytes

Versions: 4

Compression:

Stored size: 765 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

4 entries across 4 versions & 1 rubygems

Version Path
kanji-web-0.3.1 lib/kanji/templates/app/types/type.rb.tt
kanji-web-0.3.0 lib/kanji/templates/app/types/type.rb.tt
kanji-web-0.2.2 lib/kanji/templates/app/types/type.rb.tt
kanji-web-0.2.1 lib/kanji/templates/app/types/type.rb.tt