Class: Locomotive::Steam::Liquid::Drops::ContentEntryCollection

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

Instance Method Summary collapse

Constructor Details

#initialize(content_type, repository = nil) ⇒ ContentEntryCollection

Returns a new instance of ContentEntryCollection.



10
11
12
13
# File 'lib/locomotive/steam/liquid/drops/content_entry_collection.rb', line 10

def initialize(content_type, repository = nil)
  @content_type = content_type
  @repository   = repository
end

Instance Method Details

#allObject



15
16
17
18
19
20
21
22
23
# File 'lib/locomotive/steam/liquid/drops/content_entry_collection.rb', line 15

def all
  collection.map do |entry|
    entry.to_liquid.tap do |drop|
      if drop && drop.respond_to?(:context=)
        drop.context = @context
      end
    end
  end
end

#apiObject



36
37
38
39
# File 'lib/locomotive/steam/liquid/drops/content_entry_collection.rb', line 36

def api
  Locomotive::Common::Logger.warn "[Liquid template] the api for content_types has been deprecated and replaced by public_submission_url instead."
  { 'create' => public_submission_url }
end

#before_method(meth) ⇒ Object



41
42
43
44
45
46
47
48
49
50
# File 'lib/locomotive/steam/liquid/drops/content_entry_collection.rb', line 41

def before_method(meth)
  if (meth.to_s =~ /^group_by_(.+)$/) == 0
    repository.group_by_select_option($1)
  elsif (meth.to_s =~ /^(.+)_options$/) == 0
    select_options($1)
  else
    Locomotive::Common::Logger.warn "[Liquid template] trying to call #{meth} on a content_type object"
    nil
  end
end

#countObject Also known as: size, length



25
26
27
# File 'lib/locomotive/steam/liquid/drops/content_entry_collection.rb', line 25

def count
  repository.count(conditions)
end

#public_submission_urlObject



32
33
34
# File 'lib/locomotive/steam/liquid/drops/content_entry_collection.rb', line 32

def public_submission_url
  services.url_builder.public_submission_url_for(@content_type)
end