Class: Object

Inherits:
BasicObject
Defined in:
lib/adhearsion/foundation/object.rb,
lib/adhearsion/foundation/thread_safety.rb,
lib/adhearsion/foundation/exception_handler.rb

Instance Method Summary (collapse)

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

- (Object) method_missing(method_id, *arguments, &block)



15
16
17
18
19
20
21
22
23
24
# File 'lib/adhearsion/foundation/object.rb', line 15

def method_missing(method_id, *arguments, &block)
  if method_id == Adhearsion::Logging::METHOD
    self.class.send :define_method, method_id do
      Logging.logger[logger_id]
    end
    Logging.logger[logger_id]
  else
    super
  end
end

Instance Method Details

- (Object) catching_standard_errors(l = logger, &block)



4
5
6
7
8
9
10
# File 'lib/adhearsion/foundation/exception_handler.rb', line 4

def catching_standard_errors(l = logger, &block)
  begin
    yield
  rescue StandardError => e
    Adhearsion::Events.trigger :exception, [e, l]
  end
end

- (Object) logger_id



11
12
13
# File 'lib/adhearsion/foundation/object.rb', line 11

def logger_id
  self
end

- (Object) pb_logger



7
8
9
# File 'lib/adhearsion/foundation/object.rb', line 7

def pb_logger
  logger
end

- (Boolean) respond_to?(method_id, include_private = false)

Returns:

  • (Boolean)


26
27
28
29
30
# File 'lib/adhearsion/foundation/object.rb', line 26

def respond_to?(method_id, include_private = false)
  return true if method_id == Adhearsion::Logging::METHOD

  super
end

- (Object) synchronize(&block)



6
7
8
9
# File 'lib/adhearsion/foundation/thread_safety.rb', line 6

def synchronize(&block)
  @mutex ||= Mutex.new
  @mutex.synchronize(&block)
end