Class: Locomotive::Steam::Liquid::Drops::ProxyCollection

Inherits:
Liquid::Drop
  • Object
show all
Includes:
Scopeable
Defined in:
lib/locomotive/steam/liquid/drops/content_types.rb

Instance Method Summary collapse

Methods included from Scopeable

#_apply_scope_order, #apply_scope

Methods inherited from Liquid::Drop

#mounting_point, #site

Constructor Details

#initialize(content_type) ⇒ ProxyCollection

Returns a new instance of ProxyCollection.



18
19
20
21
# File 'lib/locomotive/steam/liquid/drops/content_types.rb', line 18

def initialize(content_type)
  @content_type = content_type
  @collection = nil
end

Instance Method Details

#allObject



23
24
25
# File 'lib/locomotive/steam/liquid/drops/content_types.rb', line 23

def all
  self.collection
end

#anyObject



27
28
29
# File 'lib/locomotive/steam/liquid/drops/content_types.rb', line 27

def any
  self.collection.any?
end

#apiObject



54
55
56
# File 'lib/locomotive/steam/liquid/drops/content_types.rb', line 54

def api
  { 'create' => "/entry_submissions/#{@content_type.slug}" }
end

#before_method(meth) ⇒ Object



58
59
60
61
62
63
64
65
66
# File 'lib/locomotive/steam/liquid/drops/content_types.rb', line 58

def before_method(meth)
  if (meth.to_s =~ /^group_by_(.+)$/) == 0
    self.group_entries_by(@content_type, $1)
  elsif (meth.to_s =~ /^(.+)_options$/) == 0
    self.select_options_for(@content_type, $1)
  else
    @content_type.send(meth)
  end
end

#each(&block) ⇒ Object



46
47
48
# File 'lib/locomotive/steam/liquid/drops/content_types.rb', line 46

def each(&block)
  self.collection.each(&block)
end

#firstObject



31
32
33
# File 'lib/locomotive/steam/liquid/drops/content_types.rb', line 31

def first
  self.collection.first
end

#lastObject



35
36
37
# File 'lib/locomotive/steam/liquid/drops/content_types.rb', line 35

def last
  self.collection.last
end

#public_submission_urlObject



50
51
52
# File 'lib/locomotive/steam/liquid/drops/content_types.rb', line 50

def public_submission_url
  "/entry_submissions/#{@content_type.slug}"
end

#sizeObject Also known as: length, count



39
40
41
# File 'lib/locomotive/steam/liquid/drops/content_types.rb', line 39

def size
  self.collection.size
end