Sha256: b74a7a408377cd7c467d5ecb86335d58866f85fecc5c2a31e17a79f6f627692e

Contents?: true

Size: 1.27 KB

Versions: 16

Compression:

Stored size: 1.27 KB

Contents

module Flydata
module PluginSupport
  class Context

    def self.mandatory_opts
      @mandatory_opts ||= []
    end

    def self.optional_opts
      @optional_opts ||= []
    end

    def self.register_mandatory_opts(*opts)
      @mandatory_opts ||= []
      opts.each {|opt|
        @mandatory_opts << opt.to_sym
        attr_accessor opt
      }
      nil
    end

    def self.register_optional_opts(*opts)
      @optional_opts ||= []
      opts.each {|opt|
        @optional_opts << opt.to_sym
        attr_accessor opt
      }
      nil
    end

    register_mandatory_opts :tables,
                            :tag,
                            :sync_fm,
                            :omit_events,
                            :table_revs,
                            :table_meta

    register_optional_opts  :cur_src_pos_file,
                            :table_src_pos_files,
                            :params

    def initialize(opts)
      missing_opts = self.class.mandatory_opts - opts.keys
      unless (missing_opts.empty?)
        raise "Mandatory option(s) are missing: #{missing_opts.join(', ')}"
      end

      opts.each do |k, v|
        self.instance_variable_set(:"@#{k}", v)
      end
    end

    def source_pos_class
      self.class::SOURCE_POS_CLASS
    end
  end
end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
flydata-0.7.15 lib/flydata/plugin_support/context.rb
flydata-0.7.14 lib/flydata/plugin_support/context.rb
flydata-0.7.13 lib/flydata/plugin_support/context.rb
flydata-0.7.12 lib/flydata/plugin_support/context.rb
flydata-0.7.11 lib/flydata/plugin_support/context.rb
flydata-0.7.10 lib/flydata/plugin_support/context.rb
flydata-0.7.9 lib/flydata/plugin_support/context.rb
flydata-0.7.8 lib/flydata/plugin_support/context.rb
flydata-0.7.7 lib/flydata/plugin_support/context.rb
flydata-0.7.6 lib/flydata/plugin_support/context.rb
flydata-0.7.5 lib/flydata/plugin_support/context.rb
flydata-0.7.4 lib/flydata/plugin_support/context.rb
flydata-0.7.2.1 lib/flydata/plugin_support/context.rb
flydata-0.7.2 lib/flydata/plugin_support/context.rb
flydata-0.7.1 lib/flydata/plugin_support/context.rb
flydata-0.7.0 lib/flydata/plugin_support/context.rb