Sha256: 53ff3cfb4fa8363bccf53d60bd5222abc420572789fec2e45e96be7c28b6357c

Contents?: true

Size: 1.08 KB

Versions: 9

Compression:

Stored size: 1.08 KB

Contents

module Yaks
  class Mapper
    class Config
      include Attributes.new(
                type: nil, attributes: [], links: [], associations: [], controls: []
              ),
              Configurable

      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 :attribute, create: Attribute,               append_to: :attributes
      config_method :control,
                    create: StatefulBuilder.new(Control, Control.anima.attribute_names + [:field]),
                    append_to: :controls
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
yaks-0.7.5 lib/yaks/mapper/config.rb
yaks-0.7.4 lib/yaks/mapper/config.rb
yaks-0.7.3 lib/yaks/mapper/config.rb
yaks-0.7.2 lib/yaks/mapper/config.rb
yaks-0.7.1 lib/yaks/mapper/config.rb
yaks-0.7.0 lib/yaks/mapper/config.rb
yaks-0.6.2 lib/yaks/mapper/config.rb
yaks-0.6.1 lib/yaks/mapper/config.rb
yaks-0.6.0 lib/yaks/mapper/config.rb