Sha256: e7fab91b8ba84071003667b32cc636eae66abdf74d42ef1b7042ec4aeb65ae09

Contents?: true

Size: 1.33 KB

Versions: 4

Compression:

Stored size: 1.33 KB

Contents

# encoding: utf-8

module Flextures
  # Flextures FactoryFilter is program to translate ActiveRecord data
  class LoadFilter
    # FactoryFilter data
    FACTORIES={}

    # set FactoryFilter
    # @params [String] table_name
    # @params [Array] options arguments ActiveRecord Model
    # @params [Proc] block FactoryFilter
    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

    # get FactoryFilter
    # @params [String|Symbol] table_name
    # @return [Proc] filter block
    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
    # FactoryDumpFilter data
    FACTORIES={}

    # set FactoryFilter
    # @params table_name
    # @params options
    # @params block
    # @return Flextures::Factory
    def self.define( table_name, hash )
      FACTORIES[table_name.to_sym]=hash
    end

    # get FactoryFilter
    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

4 entries across 4 versions & 1 rubygems

Version Path
flextures-3.1.3 lib/flextures/flextures_factory.rb
flextures-3.1.2 lib/flextures/flextures_factory.rb
flextures-3.1.1 lib/flextures/flextures_factory.rb
flextures-3.1.0 lib/flextures/flextures_factory.rb