Module: WpItem::Existable
- Included in:
- WpItem
- Defined in:
- lib/common/models/wp_item/existable.rb
Instance Method Summary (collapse)
-
- (Boolean) exists?(options = {}, response = nil)
Check the existence of the WpItem If the response is supplied, it's used for the verification Otherwise a new request is done.
- - (Boolean) exists_from_response?(response, options = {}) protected
Instance Method Details
- (Boolean) exists?(options = {}, response = nil)
Check the existence of the WpItem If the response is supplied, it's used for the verification Otherwise a new request is done
14 15 16 17 18 19 |
# File 'lib/common/models/wp_item/existable.rb', line 14 def exists?( = {}, response = nil) unless response response = Browser.get(url) end exists_from_response?(response, ) end |
- (Boolean) exists_from_response?(response, options = {}) (protected)
31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/common/models/wp_item/existable.rb', line 31 def exists_from_response?(response, = {}) if [200, 401, 403].include?(response.code) if response.has_valid_hash?([:error_404_hash], [:homepage_hash]) if [:exclude_content] unless response.body.match([:exclude_content]) return true end else return true end end end false end |