Class: Eql::Adapters::ActiveRecord

Inherits:
Base
  • Object
show all
Defined in:
lib/eql/adapters/active_record.rb

Overview

ActiveRecord class is a ActiveRecord::Base adapter

Defined Under Namespace

Modules: ContextHelpers

Instance Attribute Summary

Attributes inherited from Base

#builder

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Eql::Adapters::Base

Class Method Details

.match?(conn) ⇒ Boolean

Returns:

  • (Boolean)

See Also:

  • Base#match?


26
27
28
29
# File 'lib/eql/adapters/active_record.rb', line 26

def self.match?(conn)
  defined?(::ActiveRecord::Base) &&
    conn.is_a?(::ActiveRecord::ConnectionAdapters::AbstractAdapter)
end

Instance Method Details

#connActiveRecord::ConnectionAdapters::AbstractAdapter

Get DB connection to execute a query

Returns:

  • (ActiveRecord::ConnectionAdapters::AbstractAdapter)


59
60
61
# File 'lib/eql/adapters/active_record.rb', line 59

def conn
  builder.conn || ::ActiveRecord::Base.connection
end

#executeObject

See Also:



50
51
52
# File 'lib/eql/adapters/active_record.rb', line 50

def execute
  conn.execute(sql).to_a
end

#extensionObject

See Also:



43
44
45
# File 'lib/eql/adapters/active_record.rb', line 43

def extension
  '.{sql.erb,erb.sql}'
end

#sqlStirng

Get rendered SQL

Returns:

  • (Stirng)


36
37
38
# File 'lib/eql/adapters/active_record.rb', line 36

def sql
  builder.render
end