Class: Upfluence::Utils::Thrift::Middleware::ActiveRecord

Inherits:
Object
  • Object
show all
Defined in:
lib/upfluence/utils/thrift/middleware/active_record.rb

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ ActiveRecord

Returns a new instance of ActiveRecord.



9
10
11
# File 'lib/upfluence/utils/thrift/middleware/active_record.rb', line 9

def initialize(app)
  @app = app
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/upfluence/utils/thrift/middleware/active_record.rb', line 13

def method_missing(method, *args, &block)
  @app.send(method, *args, &block)
rescue ::ActiveRecord::RecordInvalid => e
  raise Base::Exceptions::ValidationError.from_model(e.record)
rescue ::ActiveRecord::RecordNotFound
  raise Base::Exceptions::NotFound
end