diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index a024c1c..690c7bb 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -108,13 +108,14 @@ Style/BlockDelimiters: - 'spec/comma/data_extractor_spec.rb' - 'spec/comma/header_extractor_spec.rb' -# Offense count: 11 +# Offense count: 12 # Configuration parameters: AllowedConstants. Style/Documentation: Exclude: - 'spec/**/*' - 'test/**/*' - 'lib/comma/array.rb' + - 'lib/comma/collection_export.rb' - 'lib/comma/data_extractor.rb' - 'lib/comma/data_mapper_collection.rb' - 'lib/comma/extractor.rb' diff --git a/lib/comma.rb b/lib/comma.rb index 1350d1c..3a1dd78 100644 --- a/lib/comma.rb +++ b/lib/comma.rb @@ -11,10 +11,10 @@ module Comma }.freeze end -require 'comma/data_mapper_collection' if defined? DataMapper - require 'comma/options' require 'comma/generator' +require 'comma/collection_export' +require 'comma/data_mapper_collection' if defined? DataMapper require 'comma/array' require 'comma/object' diff --git a/lib/comma/array.rb b/lib/comma/array.rb index f1b1c50..f15906f 100644 --- a/lib/comma/array.rb +++ b/lib/comma/array.rb @@ -1,7 +1,5 @@ # frozen_string_literal: true class Array - def to_comma(style = :default) - Comma::Generator.new(self, style).run(:each) - end + include Comma::CollectionExport end diff --git a/lib/comma/collection_export.rb b/lib/comma/collection_export.rb new file mode 100644 index 0000000..2f88b43 --- /dev/null +++ b/lib/comma/collection_export.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +module Comma + module CollectionExport + def to_comma(style = :default) + Comma::Generator.new(self, style).run(:each) + end + end +end diff --git a/lib/comma/data_mapper_collection.rb b/lib/comma/data_mapper_collection.rb index 9f61335..d05c6cc 100644 --- a/lib/comma/data_mapper_collection.rb +++ b/lib/comma/data_mapper_collection.rb @@ -3,9 +3,7 @@ if defined?(DataMapper) module DataMapper class Collection - def to_comma(style = :default) - Comma::Generator.new(self, style).run(:each) - end + include Comma::CollectionExport end end end diff --git a/lib/comma/mongoid.rb b/lib/comma/mongoid.rb index 33d7399..fed1254 100644 --- a/lib/comma/mongoid.rb +++ b/lib/comma/mongoid.rb @@ -6,9 +6,7 @@ module Mongoid class Criteria - def to_comma(style = :default) - Comma::Generator.new(self, style).run(:each) - end + include Comma::CollectionExport end end rescue LoadError => e