Class: DurableDecorator::Util
- Inherits:
-
Object
- Object
- DurableDecorator::Util
- Defined in:
- lib/durable_decorator/util.rb
Class Method Summary collapse
- .class_name(clazz) ⇒ Object
- .full_method_name(clazz, method_name) ⇒ Object
- .logger ⇒ Object
- .method_hash(name, method) ⇒ Object
- .method_sha(method) ⇒ Object
- .symbolized_hash(hash) ⇒ Object
Class Method Details
.class_name(clazz) ⇒ Object
14 15 16 17 18 |
# File 'lib/durable_decorator/util.rb', line 14 def class_name clazz name = clazz.name || '' name = clazz.to_s if name.empty? name.to_sym end |
.full_method_name(clazz, method_name) ⇒ Object
20 21 22 |
# File 'lib/durable_decorator/util.rb', line 20 def full_method_name clazz, method_name "#{class_name(clazz)}##{method_name}" end |
.logger ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/durable_decorator/util.rb', line 35 def logger return @logger if @logger Logging.color_scheme( 'bright', :levels => { :info => :green, :warn => :yellow, :error => :red, :fatal => [:white, :on_red] } ) Logging.appenders.stdout( 'stdout', :layout => Logging.layouts.pattern( :pattern => '%-5l %c: %m\n', :color_scheme => 'bright' ) ) @logger = Logging.logger['DurableDecorator'] @logger.level = :warn Logging.logger.root.appenders = Logging.appenders.stdout @logger end |
.method_hash(name, method) ⇒ Object
24 25 26 27 28 29 |
# File 'lib/durable_decorator/util.rb', line 24 def method_hash name, method { :name => name, :sha => method_sha(method) } end |
.method_sha(method) ⇒ Object
31 32 33 |
# File 'lib/durable_decorator/util.rb', line 31 def method_sha method Digest::SHA1.hexdigest(method.source.gsub(/\s+/, ' ')) end |
.symbolized_hash(hash) ⇒ Object
4 5 6 7 8 9 10 11 12 |
# File 'lib/durable_decorator/util.rb', line 4 def symbolized_hash hash chill_hash = {} hash.each do |k,v| chill_hash[k.to_sym] = v end chill_hash end |