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