Class: Fetching
- Inherits:
-
Object
show all
- Defined in:
- lib/fetching.rb,
lib/fetching/version.rb,
lib/fetching/fetching_hash.rb,
lib/fetching/fetching_array.rb
Defined Under Namespace
Classes: FetchingArray, FetchingHash
Constant Summary
collapse
- WHITELIST =
%w[ define_singleton_method class object_id
== instance_variables instance_eval
instance_variable_get ]
- VERSION =
"0.5.0"
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(table) ⇒ Fetching
Returns a new instance of Fetching.
37
38
39
|
# File 'lib/fetching.rb', line 37
def initialize table
@table = table
end
|
Class Method Details
.from(value) ⇒ Object
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/fetching.rb', line 22
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
33
34
35
|
# File 'lib/fetching.rb', line 33
def self.from_json json, closure
from(JSON.parse json).__send__ closure
end
|
Instance Method Details
#==(other) ⇒ Object
41
42
43
|
# File 'lib/fetching.rb', line 41
def ==(other)
other.hash == hash
end
|
#hash ⇒ Object
45
46
47
|
# File 'lib/fetching.rb', line 45
def hash
self.class.hash ^ @table.hash
end
|
#inspect ⇒ Object
53
54
55
|
# File 'lib/fetching.rb', line 53
def inspect
"#<#{self.class.name}: @table=#{to_s}>"
end
|
#to_s ⇒ Object
49
50
51
|
# File 'lib/fetching.rb', line 49
def to_s
@table.to_s
end
|