Class: Multitenant::List

Inherits:
Object
  • Object
show all
Defined in:
lib/generators/multitenant/views_and_triggers/list/list.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(sql = nil) ⇒ List

Returns a new instance of List.



5
6
7
# File 'lib/generators/multitenant/views_and_triggers/list/list.rb', line 5

def initialize(sql = nil)
  @sql = sql
end

Instance Attribute Details

#sqlObject

Returns the value of attribute sql.



3
4
5
# File 'lib/generators/multitenant/views_and_triggers/list/list.rb', line 3

def sql
  @sql
end

Instance Method Details

#exists?(name) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/generators/multitenant/views_and_triggers/list/list.rb', line 13

def exists?(name)
  to_a.include?(name)
end

#to_aObject



9
10
11
# File 'lib/generators/multitenant/views_and_triggers/list/list.rb', line 9

def to_a
  ActiveRecord::Base.connection.execute(sql).to_a.flatten
end