Module: Decanter
- Defined in:
- lib/decanter.rb,
lib/decanter/base.rb,
lib/decanter/core.rb,
lib/decanter/decant.rb,
lib/decanter/parser.rb,
lib/decanter/railtie.rb,
lib/decanter/version.rb,
lib/decanter/exceptions.rb,
lib/decanter/extensions.rb,
lib/decanter/parser/base.rb,
lib/decanter/parser/core.rb,
lib/decanter/parser/utils.rb,
lib/decanter/configuration.rb,
lib/decanter/parser/date_parser.rb,
lib/decanter/parser/hash_parser.rb,
lib/decanter/parser/join_parser.rb,
lib/decanter/parser/pass_parser.rb,
lib/decanter/parser/time_parser.rb,
lib/decanter/parser/float_parser.rb,
lib/decanter/parser/phone_parser.rb,
lib/decanter/parser/value_parser.rb,
lib/decanter/parser/string_parser.rb,
lib/decanter/parser/boolean_parser.rb,
lib/decanter/parser/integer_parser.rb,
lib/decanter/parser/date_time_parser.rb,
lib/generators/decanter/install_generator.rb,
lib/decanter/parser/key_value_splitter_parser.rb
Defined Under Namespace
Modules: Core, Decant, Extensions, Generators, Parser
Classes: Base, Configuration, Railtie
Constant Summary
collapse
- VERSION =
'2.1.0'.freeze
Class Method Summary
collapse
Class Method Details
.config {|configuration| ... } ⇒ Object
42
43
44
|
# File 'lib/decanter.rb', line 42
def config
yield configuration
end
|
.decanter_for(klass_or_sym) ⇒ Object
7
8
9
10
11
12
13
14
15
16
17
18
|
# File 'lib/decanter.rb', line 7
def decanter_for(klass_or_sym)
decanter_name =
case klass_or_sym
when Class
klass_or_sym.name
when Symbol
klass_or_sym.to_s.singularize.camelize
else
raise ArgumentError, "cannot lookup decanter for #{klass_or_sym} with class #{klass_or_sym.class}"
end + 'Decanter'
decanter_name.constantize
end
|
.decanter_from(klass_or_string) ⇒ Object
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/decanter.rb', line 20
def decanter_from(klass_or_string)
constant =
case klass_or_string
when Class
klass_or_string
when String
klass_or_string.constantize
else
raise ArgumentError, "cannot find decanter from #{klass_or_string} with class #{klass_or_string.class}"
end
unless constant.ancestors.include? Decanter::Base
raise ArgumentError, "#{constant.name} is not a decanter"
end
constant
end
|