Class: Hold::Sequel::QueryArrayCell

Inherits:
Object
  • Object
show all
Includes:
ArrayCell
Defined in:
lib/hold/sequel/query_array_cell.rb

Overview

Query an array cell

Instance Method Summary collapse

Methods included from ArrayCell

#can_get_class?, #can_get_item_class?, #can_set_class?, #can_set_item_class?, #get_lazy_array

Methods included from Cell

#can_get_class?, #can_set_class?, #clear, #empty?, #get_unless_empty, #set_if_empty, #set_unless_empty, #value, #value=

Constructor Details

#initialize(repo, *_query_args, &query_block) ⇒ QueryArrayCell

Returns a new instance of QueryArrayCell.



7
8
9
# File 'lib/hold/sequel/query_array_cell.rb', line 7

def initialize(repo, *_query_args, &query_block)
  @repo, @query_block = repo, query_block
end

Instance Method Details

#get(properties = nil) ⇒ Object



11
12
13
# File 'lib/hold/sequel/query_array_cell.rb', line 11

def get(properties = nil)
  @repo.query(properties, &@query_block).to_a
end

#lengthObject Also known as: get_length



20
21
22
# File 'lib/hold/sequel/query_array_cell.rb', line 20

def length
  Query.new(@repo, [], &@query_block).to_a(true).length
end

#slice(start, length, properties = nil) ⇒ Object Also known as: get_slice



15
16
17
# File 'lib/hold/sequel/query_array_cell.rb', line 15

def slice(start, length, properties = nil)
  @repo.query(properties, &@query_block).to_a(true)[start, length]
end