Module: PassionView::Relation

Defined in:
lib/passion_view/relation.rb

Instance Method Summary collapse

Instance Method Details

#countObject



27
28
29
# File 'lib/passion_view/relation.rb', line 27

def count
  items.count
end

#empty?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/passion_view/relation.rb', line 39

def empty?
  items.empty?
end

#firstObject



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

def first
  item_view_model(items.first)
end

#include?(obj) ⇒ Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/passion_view/relation.rb', line 35

def include?(obj)
  items.include?(obj)
end

#itemsObject

delegate :to_sql,

:offset_value,
:total_count,
:limit_value,
to: :scoped


8
9
10
11
12
13
14
15
16
17
# File 'lib/passion_view/relation.rb', line 8

def items
  case (items = super)
  when ActiveRecord::Relation
    items
  when ActiveRecord::Base
    items.where(nil)
  else
    raise TypeError, "not an ActiveRecord object: #{items.class}"
  end
end

#lastObject



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

def last
  item_view_model(items.first)
end

#limit_valueObject



55
56
57
# File 'lib/passion_view/relation.rb', line 55

def limit_value
  items.limit_value
end

#offset_valueObject



47
48
49
# File 'lib/passion_view/relation.rb', line 47

def offset_value
  items.offset_value
end

#sizeObject



31
32
33
# File 'lib/passion_view/relation.rb', line 31

def size
  items.size
end

#to_sqlObject



43
44
45
# File 'lib/passion_view/relation.rb', line 43

def to_sql
  items.to_sql
end

#total_countObject



51
52
53
# File 'lib/passion_view/relation.rb', line 51

def total_count
  items.total_count
end