lib/arrest/source.rb in arrest-0.0.7 vs lib/arrest/source.rb in arrest-0.0.8
- old
+ new
@@ -1,13 +1,19 @@
module Arrest
+ def self.debug s
+ if Arrest::Source.debug
+ puts s
+ end
+ end
class Source
class << self
attr_accessor :debug
attr_reader :source
attr_reader :mod
attr_reader :header_decorator
+ attr_accessor :json_key_converter
def source=(host=nil)
if host == nil || host.blank?
@source = MemSource.new
else
@@ -25,11 +31,11 @@
raise "Expected module but got #{mod.class.name}"
end
end
def header_decorator=(hd=nil)
- puts "Setting headerd to #{hd}"
+ Arrest::debug "Setting headerd to #{hd}"
if hd == nil
@header_decorator = self
elsif hd.respond_to?(:headers)
@header_decorator = hd
else
@@ -39,11 +45,21 @@
def headers
{}
end
+ def key_from_json name
+ StringUtils.underscore(name.to_s)
+ end
+
+ def key_to_json name
+ StringUtils.classify(name.to_s,false)
+ end
+
end
end
Source.mod = nil
Source.header_decorator = Source
Source.debug = false
+ Source.json_key_converter = Source
+
end