Sha256: 8025b4df1014c508e36461b5cf7691c01b21481e250a8b90495e747913da24e6

Contents?: true

Size: 750 Bytes

Versions: 6

Compression:

Stored size: 750 Bytes

Contents

require "kanji/type/attribute"
require "kanji/instance_define"
require "kanji/errors"

module Kanji
  class Type
    class AttributeDefiner
      extend Kanji::InstanceDefine

      instance_define :type, :description, :options, :resolve

      def initialize(name, type = nil, description = nil, **kwargs, &block)
        @_name = name
        @_type = type
        @_description = description
        @_options = kwargs
        self.instance_eval &block if block_given?

        raise AttributeError unless @_type
      end

      def call
        Attribute.new({
          name: @_name,
          type: @_type,
          description: @_description,
          options: @_options,
          resolve: @_resolve
        })
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
kanji-web-0.3.1 lib/kanji/type/attribute_definer.rb
kanji-web-0.3.0 lib/kanji/type/attribute_definer.rb
kanji-web-0.2.2 lib/kanji/type/attribute_definer.rb
kanji-web-0.2.1 lib/kanji/type/attribute_definer.rb
kanji-web-0.2.0 lib/kanji/type/attribute_definer.rb
kanji-web-0.1.0 lib/kanji/type/attribute_definer.rb