Sha256: bd065a23cc847f95e2dbdab79a627370490947d11ea0c83191819b9da0d97e26

Contents?: true

Size: 851 Bytes

Versions: 1

Compression:

Stored size: 851 Bytes

Contents

module Yaks
  class Mapper
    class Config
      extend Configurable

      include Attributes.new(
                type: nil, attributes: [], links: [], associations: [], forms: []
              )

      def type(type = Undefined)
        return @type if type.equal?(Undefined)
        update(type: type)
      end

      def attributes(*attrs)
        return @attributes if attrs.empty?
        append_to(:attributes, *attrs.map(&Attribute.method(:new)))
      end

      config_method :link,      create: Link,      append_to: :links
      config_method :has_one,   create: HasOne,    append_to: :associations
      config_method :has_many,  create: HasMany,   append_to: :associations
      config_method :attribute, create: Attribute, append_to: :attributes
      config_method :form,      create: Form,      append_to: :forms
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
yaks-0.7.7 lib/yaks/mapper/config.rb