Class: Locomotive::Liquid::Drops::ContentTypeProxyCollection

Inherits:
ProxyCollection
  • Object
show all
Defined in:
lib/locomotive/liquid/drops/content_types.rb

Instance Method Summary collapse

Methods inherited from ProxyCollection

#all, #any, #content_type, #count, #each, #each_with_index, #empty, #first, #last

Constructor Details

#initialize(content_type) ⇒ ContentTypeProxyCollection

Returns a new instance of ContentTypeProxyCollection.



15
16
17
18
# File 'lib/locomotive/liquid/drops/content_types.rb', line 15

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

Instance Method Details

#apiObject



24
25
26
27
# File 'lib/locomotive/liquid/drops/content_types.rb', line 24

def api
  Locomotive.log :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



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/locomotive/liquid/drops/content_types.rb', line 29

def before_method(meth)
  klass = @content_type.entries.klass # delegate to the proxy class

  if (meth.to_s =~ /^group_by_(.+)$/) == 0
    klass.send(:group_by_select_option, $1, @content_type.order_by_definition)
  elsif (meth.to_s =~ /^(.+)_options$/) == 0
    klass.send(:"#{$1}_options").map { |option| option['name'] }
  else
    Locomotive.log :warn, "[Liquid template] trying to call #{meth} on a content_type object"
  end
end

#public_submission_urlObject



20
21
22
# File 'lib/locomotive/liquid/drops/content_types.rb', line 20

def public_submission_url
  @context.registers[:controller].main_app.locomotive_entry_submissions_path(@content_type.slug)
end