class Locomotive::Wagon::PushContentTypesCommand
Attributes
step[R]
Public Instance Methods
_push()
click to toggle source
# File lib/locomotive/wagon/commands/push_sub_commands/push_content_types_command.rb, line 9 def _push %i(without_relationships only_relationships).each do |step| @step = step default_push end end
Also aliased as: default_push
decorate(entity)
click to toggle source
# File lib/locomotive/wagon/commands/push_sub_commands/push_content_types_command.rb, line 20 def decorate(entity) if without_relationships? ContentTypeDecorator.new(entity, remote_fields_for(entity.slug)) else ContentTypeWithOnlyRelationshipsDecorator.new(entity) end end
entities()
click to toggle source
# File lib/locomotive/wagon/commands/push_sub_commands/push_content_types_command.rb, line 16 def entities repositories.content_type.all end
label_for(decorated_entity)
click to toggle source
# File lib/locomotive/wagon/commands/push_sub_commands/push_content_types_command.rb, line 34 def label_for(decorated_entity) name = decorated_entity.name if without_relationships? name else "#{name} with relationships" end end
persist(decorated_entity)
click to toggle source
# File lib/locomotive/wagon/commands/push_sub_commands/push_content_types_command.rb, line 28 def persist(decorated_entity) raise SkipPersistingException.new if only_relationships? && !decorated_entity.with_relationships? api_client.content_types.update(decorated_entity.slug, decorated_entity.to_hash) end
Private Instance Methods
only_relationships?()
click to toggle source
# File lib/locomotive/wagon/commands/push_sub_commands/push_content_types_command.rb, line 64 def only_relationships? self.step == :only_relationships end
remote_entities()
click to toggle source
# File lib/locomotive/wagon/commands/push_sub_commands/push_content_types_command.rb, line 50 def remote_entities return @remote_entities if @remote_entities @remote_entities = {}.tap do |hash| api_client.content_types.all.each do |entity| hash[entity.slug] = entity end end end
remote_fields_for(slug)
click to toggle source
# File lib/locomotive/wagon/commands/push_sub_commands/push_content_types_command.rb, line 46 def remote_fields_for(slug) (remote_entities[slug].try(:fields) || []).map { |f| f['name'] } end
without_relationships?()
click to toggle source
# File lib/locomotive/wagon/commands/push_sub_commands/push_content_types_command.rb, line 60 def without_relationships? self.step == :without_relationships end