Class: JunglePath::Query::Filter

Inherits:
Object
  • Object
show all
Defined in:
lib/jungle_path/query/filter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(table_name, pk_filter_query, not_in = false) ⇒ Filter

Returns a new instance of Filter.



11
12
13
14
15
# File 'lib/jungle_path/query/filter.rb', line 11

def initialize table_name, pk_filter_query, not_in=false
  @table_name = table_name.to_sym
  @pk_filter_query = pk_filter_query
  @not_in = not_in
end

Instance Attribute Details

#not_inObject (readonly)

Returns the value of attribute not_in.



10
11
12
# File 'lib/jungle_path/query/filter.rb', line 10

def not_in
  @not_in
end

#pk_filter_queryObject (readonly)

Returns the value of attribute pk_filter_query.



10
11
12
# File 'lib/jungle_path/query/filter.rb', line 10

def pk_filter_query
  @pk_filter_query
end

#table_nameObject (readonly)

Returns the value of attribute table_name.



10
11
12
# File 'lib/jungle_path/query/filter.rb', line 10

def table_name
  @table_name
end

Instance Method Details

#fk_in_query(table_alias, fk_column_name) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/jungle_path/query/filter.rb', line 17

def fk_in_query table_alias, fk_column_name
  if @not_in
    "#{table_alias}.#{fk_column_name} not in (#{@pk_filter_query})"
  else
    "#{table_alias}.#{fk_column_name} in (#{@pk_filter_query})"
  end
end

#to_hObject



29
30
31
# File 'lib/jungle_path/query/filter.rb', line 29

def to_h
  to_hash
end

#to_hashObject



25
26
27
# File 'lib/jungle_path/query/filter.rb', line 25

def to_hash
  {table_name: @table_name, pk_filter_query: @pk_filter_query, not_in: @not_in}
end