Class: RemotePartial::Partial
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from YamlStore
all, count, create, 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
|
Instance Method Details
#criteria ⇒ Object
20
21
22
|
# File 'lib/remote_partial/partial.rb', line 20
def criteria
super if present?(super)
end
|
#default_repeat_period ⇒ Object
32
33
34
|
# File 'lib/remote_partial/partial.rb', line 32
def default_repeat_period
TimeCalc.minutes(1)
end
|
#output_file_name ⇒ Object
7
8
9
|
# File 'lib/remote_partial/partial.rb', line 7
def output_file_name
[partial_folder, file_name].join("/")
end
|
#reset_stale_at ⇒ Object
40
41
42
43
|
# File 'lib/remote_partial/partial.rb', line 40
def reset_stale_at
self.stale_at = (Time.now + repeat_period)
save
end
|
#resource_manager ⇒ Object
24
25
26
|
# File 'lib/remote_partial/partial.rb', line 24
def resource_manager
ResourceManager.new(url, criteria, &output_modifier_to_lambda)
end
|
#stale? ⇒ Boolean
49
50
51
|
# File 'lib/remote_partial/partial.rb', line 49
def stale?
stale_at_blank? or stale_at < Time.now
end
|
#to_hash ⇒ Object
53
54
55
|
# File 'lib/remote_partial/partial.rb', line 53
def to_hash
super.merge('stale_at' => stale_at)
end
|
#update_file ⇒ Object
11
12
13
14
|
# File 'lib/remote_partial/partial.rb', line 11
def update_file
resource_manager.output_to(output_file_name)
update_stale_at
end
|
#update_stale_at ⇒ Object
36
37
38
|
# File 'lib/remote_partial/partial.rb', line 36
def update_stale_at
reset_stale_at if stale?
end
|
#update_stale_file ⇒ Object
16
17
18
|
# File 'lib/remote_partial/partial.rb', line 16
def update_stale_file
update_file if stale?
end
|