Sha256: 46de26a1be29f1b2ed3f87f5c05f1dfa2b3b90e4c4e8dce1a55d123ca824e8b3

Contents?: true

Size: 629 Bytes

Versions: 4

Compression:

Stored size: 629 Bytes

Contents

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

module Yaks
  class Mapper
    module ClassMethods
      include Forwardable
      include Util

      CONFIG_METHODS = [
        :attributes,
        :link,
        :profile,
        # :embed,
        :has_one,
        :has_many
      ]

      def config
        @config ||= Config.new
        @config = yield(@config) if block_given?
        @config
      end

      def inherited(child)
        child.config { @config }
      end

      CONFIG_METHODS.each do |method_name|
        define_method method_name do |*args|
          config &σ(method_name, *args)
        end
      end

    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
yaks-0.3.1 lib/yaks/mapper/class_methods.rb
yaks-0.3.0 lib/yaks/mapper/class_methods.rb
yaks-0.2.0 lib/yaks/mapper/class_methods.rb
yaks-0.1.0 lib/yaks/mapper/class_methods.rb