Class: Fetching
- Inherits:
-
Object
show all
- Defined in:
- lib/fetching.rb,
lib/fetching/version.rb
Constant Summary
collapse
- WHITELIST =
%w[ define_singleton_method class object_id
== inspect to_s instance_variables instance_eval
instance_variable_get ]
- VERSION =
"0.4.1"
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(table) ⇒ Fetching
Returns a new instance of Fetching.
34
35
36
|
# File 'lib/fetching.rb', line 34
def initialize table
@table = table
end
|
Class Method Details
.from(value) ⇒ Object
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/fetching.rb', line 19
def self.from(value)
case value
when ->(v) { v.respond_to? :to_ary }
FetchingArray.new(value.to_ary)
when ->(v) { v.respond_to? :to_hash }
FetchingHash.new(value.to_hash)
else
value
end
end
|
.from_json(json, closure) ⇒ Object
30
31
32
|
# File 'lib/fetching.rb', line 30
def self.from_json json, closure
from(JSON.parse json).__send__ closure
end
|
Instance Method Details
#==(other) ⇒ Object
38
39
40
|
# File 'lib/fetching.rb', line 38
def ==(other)
other.hash == hash
end
|
#hash ⇒ Object
42
43
44
|
# File 'lib/fetching.rb', line 42
def hash
self.class.hash ^ @table.hash
end
|