Sha256: 6570ca0c927123e5bdf87ca479c27a4c32e49bf73b07c7508b271622a50d95dd

Contents?: true

Size: 760 Bytes

Versions: 14

Compression:

Stored size: 760 Bytes

Contents

module ZTK::DSL::Core

  # @author Zachary Patten <zachary AT jovelabs DOT com>
  # @api private
  module Relations
    require 'ztk/dsl/core/relations/belongs_to'
    require 'ztk/dsl/core/relations/has_many'

    def self.included(base)
      base.class_eval do
        base.send(:extend, ZTK::DSL::Core::Relations::ClassMethods)
        base.send(:include, ZTK::DSL::Core::Relations::BelongsTo)
        base.send(:include, ZTK::DSL::Core::Relations::HasMany)
      end
    end

    # @author Zachary Patten <zachary AT jovelabs DOT com>
    module ClassMethods

      def add_relation(key)
        relation_key = "#{key}_relations"
        cattr_accessor relation_key
        send(relation_key) || send("#{relation_key}=", {})
      end

    end

  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
ztk-3.1.0 lib/ztk/dsl/core/relations.rb
ztk-3.0.4 lib/ztk/dsl/core/relations.rb
ztk-3.0.3 lib/ztk/dsl/core/relations.rb
ztk-3.0.2 lib/ztk/dsl/core/relations.rb
ztk-3.0.1 lib/ztk/dsl/core/relations.rb
ztk-3.0.0 lib/ztk/dsl/core/relations.rb
ztk-2.4.2 lib/ztk/dsl/core/relations.rb
ztk-2.4.1 lib/ztk/dsl/core/relations.rb
ztk-2.4.0 lib/ztk/dsl/core/relations.rb
ztk-2.3.1 lib/ztk/dsl/core/relations.rb
ztk-2.3.0 lib/ztk/dsl/core/relations.rb
ztk-2.2.0 lib/ztk/dsl/core/relations.rb
ztk-2.1.1 lib/ztk/dsl/core/relations.rb
ztk-2.1.0 lib/ztk/dsl/core/relations.rb