Sha256: d315d1b597476514ca49b62862c7897a8fac36b61fb8811a19e0a610bfb9d55f

Contents?: true

Size: 790 Bytes

Versions: 1

Compression:

Stored size: 790 Bytes

Contents

module StoreSchema::Module

  def self.included(base)
    base.extend(ClassMethods)
  end

  module ClassMethods

    # @example
    #
    #   # Gemfile
    #   gem "store_schema"
    #
    #   # app/models/website.rb
    #   class Website < ActiveRecord::Base
    #
    #     store_schema :config do |s|
    #       s.string   :name
    #       s.integer  :visitors
    #       s.float    :apdex
    #       s.boolean  :ssl
    #       s.datetime :published_at
    #     end
    #   end
    #
    # @param column [Symbol] name of the table column
    # @param block [Proc] the configuration block
    #
    def store_schema(column, &block)
      StoreSchema::Configuration.new(column).tap do |config|
        yield(config)
        config.send(:configure, self)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
store_schema-1.1.0 lib/store_schema/module.rb