class Locomotive::Wagon::ContentEntryDecorator

Constants

DEFAULT_ATTRIBUTES

Attributes

__base_path__[RW]
__content_assets_pusher__[RW]

Public Class Methods

new(object, locale = nil, base_path, content_assets_pusher) click to toggle source
Calls superclass method
# File lib/locomotive/wagon/decorators/content_entry_decorator.rb, line 13
def initialize(object, locale = nil, base_path, content_assets_pusher)
  self.__base_path__ = base_path
  self.__content_assets_pusher__ = content_assets_pusher
  super(object, locale, nil)
end

Public Instance Methods

__attributes__() click to toggle source
# File lib/locomotive/wagon/decorators/content_entry_decorator.rb, line 27
def __attributes__
  DEFAULT_ATTRIBUTES + fields.no_associations.map { |f| f.name.to_sym }
end
_id() click to toggle source
# File lib/locomotive/wagon/decorators/content_entry_decorator.rb, line 23
def _id
  __getobj__[:remote_id] || self._slug
end
_id=(id) click to toggle source
# File lib/locomotive/wagon/decorators/content_entry_decorator.rb, line 19
def _id=(id)
  __getobj__[:remote_id] = id
end
decorate_date_field(value) click to toggle source
# File lib/locomotive/wagon/decorators/content_entry_decorator.rb, line 54
def decorate_date_field(value)
  value.try(:iso8601)
end
decorate_date_time_field(value) click to toggle source
# File lib/locomotive/wagon/decorators/content_entry_decorator.rb, line 49
def decorate_date_time_field(value)
  return nil if value.nil?
  value.utc.try(:iso8601)
end
Also aliased as: decorate_time_field
decorate_file_field(value) click to toggle source
# File lib/locomotive/wagon/decorators/content_entry_decorator.rb, line 44
def decorate_file_field(value)
  return nil if value.nil? || value.filename.blank?
  asset_io(File.join(value.base, value.filename))
end
decorate_json_field(value) click to toggle source
# File lib/locomotive/wagon/decorators/content_entry_decorator.rb, line 58
def decorate_json_field(value)
  value.to_json
end
decorate_text_field(value) click to toggle source
# File lib/locomotive/wagon/decorators/content_entry_decorator.rb, line 40
def decorate_text_field(value)
  replace_with_content_assets!(value)
end
decorate_time_field(value)
method_missing(name, *args, &block) click to toggle source
Calls superclass method
# File lib/locomotive/wagon/decorators/content_entry_decorator.rb, line 31
def method_missing(name, *args, &block)
  if field = fields.by_name(name.to_s)
    method_name = :"decorate_#{field.type}_field"
    respond_to?(method_name) ? send(method_name, super) : super
  else
    super
  end
end
to_hash() click to toggle source
# File lib/locomotive/wagon/decorators/content_entry_decorator.rb, line 64
def to_hash
  if (hash = super).keys == DEFAULT_ATTRIBUTES
    {}
  else
    hash
  end
end

Private Instance Methods

fields() click to toggle source
# File lib/locomotive/wagon/decorators/content_entry_decorator.rb, line 74
def fields
  __getobj__.content_type.fields
end