Class: RemotePartial::Builder
- Inherits:
-
Object
- Object
- RemotePartial::Builder
- Defined in:
- lib/remote_partial/builder.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#changed ⇒ Object
readonly
Returns the value of attribute changed.
-
#partial ⇒ Object
readonly
Returns the value of attribute partial.
Class Method Summary collapse
Instance Method Summary collapse
- #create_or_update_partial ⇒ Object
-
#initialize(args) ⇒ Builder
constructor
A new instance of Builder.
- #run ⇒ Object
Constructor Details
#initialize(args) ⇒ Builder
Returns a new instance of Builder.
11 12 13 |
# File 'lib/remote_partial/builder.rb', line 11 def initialize(args) @args = Partial.string_keys(args) end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
4 5 6 |
# File 'lib/remote_partial/builder.rb', line 4 def args @args end |
#changed ⇒ Object (readonly)
Returns the value of attribute changed.
4 5 6 |
# File 'lib/remote_partial/builder.rb', line 4 def changed @changed end |
#partial ⇒ Object (readonly)
Returns the value of attribute partial.
4 5 6 |
# File 'lib/remote_partial/builder.rb', line 4 def partial @partial end |
Class Method Details
.build(args) ⇒ Object
6 7 8 9 |
# File 'lib/remote_partial/builder.rb', line 6 def self.build(args) builder = new(args) builder.run end |
Instance Method Details
#create_or_update_partial ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/remote_partial/builder.rb', line 22 def create_or_update_partial @partial = Partial.find(args['name']) || Partial.new(name: args['name']) track_change(args, 'url') track_change(args, 'output_modifier') track_change(args, 'criteria') track_change(args, 'repeat_period', @partial.default_repeat_period) if changed @partial.save end end |
#run ⇒ Object
15 16 17 18 19 20 |
# File 'lib/remote_partial/builder.rb', line 15 def run create_or_update_partial partial.update_stale_file rescue RemotePartialRetrivalError => error RemotePartial.logger.warn error. end |