Class: RemotePartial::Partial
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from YamlStore
all, count, dir, file, find, merge!, read, root, #save, string_keys, #time_stamps, write
Instance Attribute Details
#repeat_period ⇒ Object
Returns the value of attribute repeat_period.
5
6
7
|
# File 'lib/remote_partial/partial.rb', line 5
def repeat_period
@repeat_period
end
|
#stale_at ⇒ Object
Returns the value of attribute stale_at.
5
6
7
|
# File 'lib/remote_partial/partial.rb', line 5
def stale_at
@stale_at
end
|
Class Method Details
.create(hash) ⇒ Object
7
8
9
10
|
# File 'lib/remote_partial/partial.rb', line 7
def self.create(hash)
super
end
|
Instance Method Details
#criteria ⇒ Object
25
26
27
|
# File 'lib/remote_partial/partial.rb', line 25
def criteria
super if present?(super)
end
|
#default_repeat_period ⇒ Object
37
38
39
|
# File 'lib/remote_partial/partial.rb', line 37
def default_repeat_period
TimeCalc.minutes(1)
end
|
#output_file_name ⇒ Object
12
13
14
|
# File 'lib/remote_partial/partial.rb', line 12
def output_file_name
[partial_folder, file_name].join("/")
end
|
#reset_stale_at ⇒ Object
45
46
47
48
|
# File 'lib/remote_partial/partial.rb', line 45
def reset_stale_at
self.stale_at = (Time.now + repeat_period)
save
end
|
#resource_manager ⇒ Object
29
30
31
|
# File 'lib/remote_partial/partial.rb', line 29
def resource_manager
ResourceManager.new(url, criteria, &output_modifier_to_lambda)
end
|
#stale? ⇒ Boolean
54
55
56
|
# File 'lib/remote_partial/partial.rb', line 54
def stale?
stale_at_blank? or stale_at < Time.now
end
|
#to_hash ⇒ Object
58
59
60
|
# File 'lib/remote_partial/partial.rb', line 58
def to_hash
super.merge('stale_at' => stale_at)
end
|
#update_file ⇒ Object
16
17
18
19
|
# File 'lib/remote_partial/partial.rb', line 16
def update_file
resource_manager.output_to(output_file_name)
update_stale_at
end
|
#update_stale_at ⇒ Object
41
42
43
|
# File 'lib/remote_partial/partial.rb', line 41
def update_stale_at
reset_stale_at if stale?
end
|
#update_stale_file ⇒ Object
21
22
23
|
# File 'lib/remote_partial/partial.rb', line 21
def update_stale_file
update_file if stale?
end
|