Module: Decanter
- Defined in:
- lib/decanter.rb,
lib/decanter/base.rb,
lib/decanter/core.rb,
lib/decanter/parser.rb,
lib/decanter/version.rb,
lib/decanter/extensions.rb,
lib/decanter/parser/base.rb,
lib/decanter/parser/core.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/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/datetime_parser.rb,
lib/generators/decanter/install_generator.rb,
lib/decanter/parser/key_value_splitter_parser.rb
Defined Under Namespace
Modules: Core, Extensions, Generators, Parser
Classes: Base, Configuration, Railtie
Constant Summary
collapse
- VERSION =
'0.8.0'
Class Method Summary
collapse
Class Method Details
.config {|configuration| ... } ⇒ Object
40
41
42
|
# File 'lib/decanter.rb', line 40
def config
yield configuration
end
|
.decanter_for(klass_or_sym) ⇒ Object
7
8
9
10
11
12
13
14
15
16
|
# File 'lib/decanter.rb', line 7
def decanter_for(klass_or_sym)
case klass_or_sym
when Class
klass_or_sym.name
when Symbol
klass_or_sym.to_s.singularize.camelize
else
raise ArgumentError.new("cannot lookup decanter for #{klass_or_sym} with class #{klass_or_sym.class}")
end.concat('Decanter').constantize
end
|
.decanter_from(klass_or_string) ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/decanter.rb', line 18
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.new("cannot find decanter from #{klass_or_string} with class #{klass_or_string.class}")
end
unless constant.ancestors.include? Decanter::Base
raise ArgumentError.new("#{constant.name} is not a decanter")
end
constant
end
|