Sha256: 891671d8e469b6f52b32332d0e5408d2a24b92d918ff55ab0a2737e5c4b3b864

Contents?: true

Size: 758 Bytes

Versions: 2

Compression:

Stored size: 758 Bytes

Contents

# encoding: utf-8
# frozen_string_literal: true

module Mixture
  # A model.
  #
  # @example
  #   class MyClass
  #     include Mixture::Model
  #     mixture_modules :attribute, :hash
  #   end
  module Model
    # The class methods for the module.
    module ClassMethods
      # Used to include certain extensions.
      #
      # @see Extensions.[]
      # @param mods [Symbol] The mod name to include.
      # @return [void]
      def mixture_modules(*mods)
        mods.each do |mod|
          include Extensions[mod]
        end
      end
    end

    # A method used internally by ruby.
    #
    # @api private
    def self.included(base)
      base.extend ClassMethods
      base.mixture_modules(:attribute, :coerce, :validate)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mixture-0.7.1 lib/mixture/model.rb
mixture-0.7.0 lib/mixture/model.rb