Sha256: e30bf3d093d22087a94e9669f7a0fbe1c05a9bd3e3a3282b90c42b54410412ce

Contents?: true

Size: 928 Bytes

Versions: 1

Compression:

Stored size: 928 Bytes

Contents

# -*- coding: utf-8 -*-

module Yaks
  class Mapper
    module ClassMethods
      extend Util::Deprecated
      include Forwardable,
              Util,
              FP

      def config(value = Undefined)
        if value.equal? Undefined
          @config
        else
          raise if value.nil?
          @config = value
        end
      end

      def inherited(child)
        child.config(config)
      end

      CONFIG_METHODS = [
        :type,
        :attributes,
        :link,
        :profile,
        :has_one,
        :has_many,
        :form
      ]

      CONFIG_METHODS.each do |method_name|
        define_method method_name do |*args, &block|
          if args.empty?
            config.public_send(method_name, *args, &block)
          else
            config(config.public_send(method_name, *args, &block))
          end
        end
      end

      deprecated_alias :control, :form
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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