Sha256: d5e3ebe838291c731adc1788736bf7bb2d796dd38b99c70ee970ad8bc925dea7
Contents?: true
Size: 1.55 KB
Versions: 6
Compression:
Stored size: 1.55 KB
Contents
require 'active_support/all' module Decanter class << self 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.new("cannot lookup decanter for #{klass_or_sym} with class #{klass_or_sym.class}") end.concat('Decanter') begin decanter_name.constantize rescue raise NameError.new("uninitialized constant #{decanter_name}") end end def decanter_from(klass_or_string) constant = case klass_or_string when Class klass_or_string when String begin klass_or_string.constantize rescue raise NameError.new("uninitialized constant #{klass_or_string}") end 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 def configuration @config ||= Decanter::Configuration.new end def config yield configuration end end ActiveSupport.run_load_hooks(:decanter, self) end require 'decanter/version' require 'decanter/configuration' require 'decanter/core' require 'decanter/base' require 'decanter/extensions' require 'decanter/parser' require 'decanter/railtie' if defined?(::Rails)
Version data entries
6 entries across 6 versions & 1 rubygems
Version | Path |
---|---|
decanter-1.0.3 | lib/decanter.rb |
decanter-1.0.2 | lib/decanter.rb |
decanter-1.0.1 | lib/decanter.rb |
decanter-0.9.2 | lib/decanter.rb |
decanter-0.9.1 | lib/decanter.rb |
decanter-0.9.0 | lib/decanter.rb |