app/services/post_upserter.rb
# The following attributes will be copied from post JSON responses
# into local Post instances.
#
The following attributes will be copied from post JSON responses
into local Post instances.
The following attributes will be copied from post JSON responses into local Post instances .
def perform(json, source_url)
    @json = json
    @source_url = source_url
    if json_sane?
      post = Post.where(guid: json['guid']).first_or_initialize
      if post.new_record? || post.edited_at < json['edited_at']
        post.attributes = json.slice(*ACCESSIBLE_JSON_ATTRIBUTES)
        post.domain = @post_uri.host
        post.slug   = @post_uri.path.sub(/^\//, '')
        post.save!
      end
      post
    end
  end
def perform ( json , source_url ) @json = json @source_url = source_url if json_sane? post = Post . where ( guid : json [ 'guid' ] ) . first_or_initialize if post . new_record? || post . edited_at < json [ 'edited_at' ] post . attributes = json . slice ( * ACCESSIBLE_JSON_ATTRIBUTES ) post . domain = @post_uri . host post . slug = @post_uri . path . sub ( / ^ \/ / , '' ) post . save! end post end end
The following attributes will be copied from post JSON responses
into local Post instances.
The following attributes will be copied from post JSON responses into local Post instances .
# Transfer whitelisted attributes # Extract #domain and #slug from #url
json
source_url