Module: Scrapify::Base
- Defined in:
- lib/scrapify/base.rb
Defined Under Namespace
Modules: ClassMethods
Constant Summary
collapse
%w(Cache-Control Last-Modified Age ETag)
Class Method Summary
collapse
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
14
15
16
|
# File 'lib/scrapify/base.rb', line 14
def method_missing(method, *args, &block)
@attributes[method] || super
end
|
Class Method Details
.included(klass) ⇒ Object
4
5
6
7
8
|
# File 'lib/scrapify/base.rb', line 4
def self.included(klass)
klass.extend ClassMethods
klass.cattr_accessor :url, :doc, :attribute_names
klass.instance_eval { attr_reader :attributes }
end
|
Instance Method Details
#initialize(attributes) ⇒ Object
10
11
12
|
# File 'lib/scrapify/base.rb', line 10
def initialize(attributes)
@attributes = attributes
end
|
#to_json(*args) ⇒ Object
18
19
20
|
# File 'lib/scrapify/base.rb', line 18
def to_json(*args)
@attributes.to_json(*args)
end
|