Module: DutyFree

Defined in:
lib/duty_free/util.rb,
lib/duty_free/column.rb,
lib/duty_free/config.rb,
lib/duty_free/extensions.rb,
lib/duty_free/version_number.rb,
lib/duty_free/serializers/json.rb,
lib/duty_free/serializers/yaml.rb,
lib/duty_free/suggest_template.rb,
lib/duty_free/frameworks/cucumber.rb,
lib/duty_free/frameworks/rails/engine.rb,
lib/generators/duty_free/model_generator.rb,
lib/duty_free/frameworks/rails/controller.rb,
lib/generators/duty_free/install_generator.rb,
lib/duty_free.rb

Overview

An ActiveRecord extension that simplifies importing and exporting of data stored in one or more models. Source and destination can be CSV, XLS, XLSX, ODT, HTML tables, or simple Ruby arrays.

Defined Under Namespace

Modules: Cucumber, Extensions, Rails, Serializers, SuggestTemplate, Util, VERSION Classes: Column, Config, InstallGenerator, LessThanHalfAreMatchingColumnsError, ModelGenerator, NoUniqueColumnError

Class Method Summary collapse

Class Method Details

.config {|@config| ... } ⇒ Object Also known as: configure

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns DutyFree’s global configuration object, a singleton. These settings affect all threads.

Yields:



116
117
118
119
120
# File 'lib/duty_free.rb', line 116

def config
  @config ||= DutyFree::Config.instance
  yield @config if block_given?
  @config
end

.enabled=(value) ⇒ Object

Switches DutyFree on or off, for all threads.



82
83
84
# File 'lib/duty_free.rb', line 82

def enabled=(value)
  DutyFree.config.enabled = value
end

.enabled?Boolean

Returns ‘true` if DutyFree is on, `false` otherwise. This is the on/off switch that affects all threads. Enabled by default.

Returns:

  • (Boolean)


89
90
91
# File 'lib/duty_free.rb', line 89

def enabled?
  !!DutyFree.config.enabled
end

.gem_versionObject

Returns DutyFree’s ‘::Gem::Version`, convenient for comparisons. This is recommended over `::DutyFree::VERSION::STRING`.



97
98
99
# File 'lib/duty_free.rb', line 97

def gem_version
  ::Gem::Version.new(VERSION::STRING)
end

.serializerObject

Get the DutyFree serializer used by all threads.



109
110
111
# File 'lib/duty_free.rb', line 109

def serializer
  DutyFree.config.serializer
end

.serializer=(value) ⇒ Object

Set the DutyFree serializer. This setting affects all threads.



103
104
105
# File 'lib/duty_free.rb', line 103

def serializer=(value)
  DutyFree.config.serializer = value
end

.versionObject



123
124
125
# File 'lib/duty_free.rb', line 123

def version
  VERSION::STRING
end