lib/csv2hash.rb in csv2hash-0.5.0 vs lib/csv2hash.rb in csv2hash-0.6.0
- old
+ new
@@ -1,6 +1,8 @@
require_relative 'csv2hash/version'
+require_relative 'csv2hash/registry'
+require_relative 'csv2hash/cell'
require_relative 'csv2hash/definition'
require_relative 'csv2hash/validator'
require_relative 'csv2hash/validator/mapping'
require_relative 'csv2hash/validator/collection'
require_relative 'csv2hash/structure_validator'
@@ -23,9 +25,27 @@
end
module Csv2hash
class Main
include Csv2hash::StructureValidator
+
+ class << self
+
+ def generate_definition name, &block
+ definition = Definition.new name, &block
+ Main[name] = definition
+ end
+
+ def [] definition_name
+ @@registry[definition_name]
+ end
+
+ def []= definition_name, role
+ @@registry[definition_name] = role
+ end
+ end
+
+ @@registry = Registry.new
attr_accessor :definition, :file_path_or_data, :data, :notifier, :break_on_failure, :errors, :options
def initialize definition, file_path_or_data, *args
self.options = args.extract_options!