Class: CrawlKit::Record

Inherits:
AWS::Record::Base
  • Object
show all
Includes:
Helpers
Defined in:
lib/crawl_kit/record.rb,
lib/crawl_kit/record/helpers.rb

Defined Under Namespace

Modules: Helpers

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Helpers

#fetched?, #hashed_uri, included, #page, #previous_version

Class Method Details

.find(id) ⇒ Object



38
39
40
# File 'lib/crawl_kit/record.rb', line 38

def find(id)
  id =~ /^[^\.]+$/ ? super(id) : super(hash_uri(id))
end

.find_or_create_by_uri(uri) ⇒ Object



42
43
44
45
46
# File 'lib/crawl_kit/record.rb', line 42

def find_or_create_by_uri(uri)
  find(hash_uri(uri))
rescue
  new(uri: uri)
end

Instance Method Details

#seed_attributesObject



49
50
51
52
53
54
55
56
57
58
# File 'lib/crawl_kit/record.rb', line 49

def seed_attributes
  Hash.new(
    site_id: site_id,
    market_id: market_id,
    crawl_node_id: crawl_node_id,
    external_region_node_id: external_region_node_id,
    external_category_node_id: external_category_node_id,
    referer: uri
  )
end

#update_blank_attributes_only(attributes) ⇒ Object



60
61
62
63
# File 'lib/crawl_kit/record.rb', line 60

def update_blank_attributes_only(attributes)
  attributes.delete_if {|key, value| send(key) }
  update_attributes(attributes)
end