Sha256: f3c1ac0cf89f8dc9501b32192c30f785ae04760f1c6c988c77dc261355813fd9

Contents?: true

Size: 1.28 KB

Versions: 13

Compression:

Stored size: 1.28 KB

Contents

# encoding: utf-8

module Flextures
  # ロードするデータを必要に応じて加工する
  class LoadFilter
    # 設置ファイルから取得した Factoryの一覧を取得
    FACTORIES={}

    # Factory を定義
    # @params table_name
    # @params options
    # @params block
    # @return Flextures::Factory
    def self.define table_name, *options, &block
      h={ block: block }
      options.each do |o|
        begin
          h[:model] = o if o.new.is_a? ActiveRecord::Base
        rescue
        end
      end
      FACTORIES[table_name.to_sym]=h
    end

    # Factoryを取得
    def self.get table_name
      f = FACTORIES[table_name.to_sym]
      f && f[:block]
    end
    def self.[](table_name); self.get(table_name); end
  end
  class DumpFilter
    # 設置ファイルから取得した Factoryの一覧を取得
    FACTORIES={}

    # Factory を定義
    # @params table_name
    # @params options
    # @params block
    # @return Flextures::Factory
    def self.define table_name, hash
      FACTORIES[table_name.to_sym]=hash
    end

    # Factoryを取得
    def self.get table_name
      FACTORIES[table_name.to_sym]
    end
    def self.[](table_name); self.get(table_name); end
  end
  Factory = LoadFilter
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
flextures-2.1.0 lib/flextures/flextures_factory.rb
flextures-2.0.9 lib/flextures/flextures_factory.rb
flextures-2.0.8 lib/flextures/flextures_factory.rb
flextures-2.0.7 lib/flextures/flextures_factory.rb
flextures-2.0.6 lib/flextures/flextures_factory.rb
flextures-2.0.5 lib/flextures/flextures_factory.rb
flextures-2.0.4 lib/flextures/flextures_factory.rb
flextures-2.0.3 lib/flextures/flextures_factory.rb
flextures-2.0.2 lib/flextures/flextures_factory.rb
flextures-2.0.1 lib/flextures/flextures_factory.rb
flextures-2.0.0 lib/flextures/flextures_factory.rb
flextures-1.9.16 lib/flextures/flextures_factory.rb
flextures-1.9.15 lib/flextures/flextures_factory.rb