Sha256: ab127ec14ae0ef680fe9f9704cd90aad9f4959f882316c332fbd928bb72e1341

Contents?: true

Size: 971 Bytes

Versions: 1

Compression:

Stored size: 971 Bytes

Contents

# frozen_string_literal: true

require 'clowne/dsl'
require 'clowne/utils/plan'

module Clowne
  module Declarations # :nodoc:
    module_function

    def add(id, declaration = nil)
      declaration = Proc.new if block_given?

      if declaration.is_a?(Class)
        DSL.send(:define_method, id) do |*args, &block|
          declarations.push declaration.new(*args, &block)
        end
      elsif declaration.is_a?(Proc)
        DSL.send(:define_method, id, &declaration)
      else
        raise ArgumentError, "Unsupported declaration type: #{declaration.class}"
      end
    end
  end
end

require 'clowne/declarations/base'
require 'clowne/declarations/init_as'
require 'clowne/declarations/exclude_association'
require 'clowne/declarations/finalize'
require 'clowne/declarations/include_association'
require 'clowne/declarations/nullify'
require 'clowne/declarations/trait'
require 'clowne/declarations/after_persist'
require 'clowne/declarations/after_clone'

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
clowne-1.1.0 lib/clowne/declarations.rb