Class: Locomotive::ContentEntryService

Inherits:
Struct
  • Object
show all
Defined in:
app/services/locomotive/content_entry_service.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#content_typeObject

Returns the value of attribute content_type

Returns:

  • (Object)

    the current value of content_type



2
3
4
# File 'app/services/locomotive/content_entry_service.rb', line 2

def content_type
  @content_type
end

Instance Method Details

#all(options = {}) ⇒ Object

List all the entries of a content type.

If the content type allows the pagination, in other words, if the entries are not ordered by the position column), then this method will return a paginated list of entries.

This list can also be filtered by the _label attribute, by setting the “q” key in the options.

For a more powerful search, you can use the “where” key which accepts a JSON string or a Hash.

Parameters:

  • options (Hash) (defaults to: {})

    The options for the pagination and the filtering

Returns:

  • (Object)

    a paginated list of content entries



18
19
20
21
22
23
24
25
26
# File 'app/services/locomotive/content_entry_service.rb', line 18

def all(options = {})
  _options = prepare_options_for_all(options)

  if _options[:grouping]
    content_type.list_or_group_entries(_options)
  else
    content_type.ordered_entries(_options)
  end
end

#destroy_allObject

Destroy all the entries of a content type. Runs each entry’s destroy callbacks.



31
32
33
# File 'app/services/locomotive/content_entry_service.rb', line 31

def destroy_all
  content_type.entries.destroy_all
end