Class: Locomotive::Wagon::PushPagesCommand
- Inherits:
-
PushBaseCommand
show all
- Defined in:
- lib/locomotive/wagon/commands/push_sub_commands/push_pages_command.rb
Instance Attribute Summary
#api_client, #content_assets_pusher, #filter, #remote_site, #steam_services
Instance Method Summary
collapse
#_push, #_push_with_timezone, #default_locale, #instrument, #locales, #only, #path, push, #push, #resource_name, #with_data, #with_data?
Instance Method Details
#decorate(entity) ⇒ Object
12
13
14
15
16
17
18
|
# File 'lib/locomotive/wagon/commands/push_sub_commands/push_pages_command.rb', line 12
def decorate(entity)
_decorate(entity).tap do |decorated|
if parent = repositories.page.parent_of(entity)
decorated[:parent] = _decorate(parent).fullpath
end
end
end
|
#entities ⇒ Object
5
6
7
8
9
10
|
# File 'lib/locomotive/wagon/commands/push_sub_commands/push_pages_command.rb', line 5
def entities
repositories.page.all.map do |entity|
next if skip?(entity)
entity
end.compact
end
|
#label_for(decorated_entity) ⇒ Object
34
35
36
37
38
39
40
41
42
|
# File 'lib/locomotive/wagon/commands/push_sub_commands/push_pages_command.rb', line 34
def label_for(decorated_entity)
_locales = translated_in(decorated_entity).join(', ')
if _locales.blank?
decorated_entity.fullpath
else
decorated_entity.fullpath + " (#{_locales})"
end
end
|
#persist(decorated_entity) ⇒ Object
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/locomotive/wagon/commands/push_sub_commands/push_pages_command.rb', line 20
def persist(decorated_entity)
decorated_entity._id = remote_id = remote_entity_id(decorated_entity)
translated_in(decorated_entity) do |locale|
if remote_id.nil?
remote_id = api_client.pages.create(decorated_entity.to_hash)._id
elsif can_update?(decorated_entity)
api_client.pages.update(remote_id, decorated_entity.to_hash, locale)
else
raise "The local and the remote (#{remote_entity_fullpath_from_handle(decorated_entity)}) versions of that page have the same handle but they are not in the same folder."
end
end
end
|