Sha256: 3214a4b1dd0157ec5f3c3ffbc72455ae668e5b7e4fabdf2a447fafbb8582586b
Contents?: true
Size: 1.32 KB
Versions: 18
Compression:
Stored size: 1.32 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, :cur_sent_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
18 entries across 18 versions & 1 rubygems