Class: QuerySet

Inherits:
Object
  • Object
show all
Defined in:
lib/query_set.rb

Defined Under Namespace

Classes: Query

Constant Summary collapse

VERSION =
'0.0.0'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(conn, path, query: Query, store: {}) ⇒ QuerySet

Returns a new instance of QuerySet.



6
7
8
9
10
11
# File 'lib/query_set.rb', line 6

def initialize(conn, path, query: Query, store: {})
  @conn = conn
  @path = path
  @query = query
  @store = store
end

Instance Attribute Details

#connObject

Returns the value of attribute conn.



4
5
6
# File 'lib/query_set.rb', line 4

def conn
  @conn
end

#pathObject

Returns the value of attribute path.



4
5
6
# File 'lib/query_set.rb', line 4

def path
  @path
end

#queryObject

Returns the value of attribute query.



4
5
6
# File 'lib/query_set.rb', line 4

def query
  @query
end

#storeObject

Returns the value of attribute store.



4
5
6
# File 'lib/query_set.rb', line 4

def store
  @store
end

Instance Method Details

#[](file_name) ⇒ Object



13
14
15
16
17
# File 'lib/query_set.rb', line 13

def [](file_name)
  store.fetch(file_name) do
    store[file_name] = query.new(File.read(path % file_name))
  end
end

#[]=(key, value) ⇒ Object



19
20
21
# File 'lib/query_set.rb', line 19

def []=(key, value)
  store[key] = value
end

#execute(file_name, *args) ⇒ Object



23
24
25
# File 'lib/query_set.rb', line 23

def execute(file_name, *args)
  self.[](file_name).execute(conn, *args)
end