Class: Sideload::Config
- Inherits:
-
Object
- Object
- Sideload::Config
- Defined in:
- lib/sideload/config.rb
Constant Summary collapse
- ALLOWED =
i[path github redis]
Instance Attribute Summary collapse
-
#packer ⇒ Object
readonly
Returns the value of attribute packer.
-
#sources ⇒ Object
readonly
Returns the value of attribute sources.
-
#unpacker ⇒ Object
readonly
Returns the value of attribute unpacker.
Instance Method Summary collapse
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #pack ⇒ Object
- #source(scope, arg, **config) ⇒ Object
- #unpack ⇒ Object
- #update! ⇒ Object
- #validate ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
7 8 9 10 11 |
# File 'lib/sideload/config.rb', line 7 def initialize @sources = [] @packer = ->(f) { f } @unpacker = ->(f) { f } end |
Instance Attribute Details
#packer ⇒ Object (readonly)
Returns the value of attribute packer.
5 6 7 |
# File 'lib/sideload/config.rb', line 5 def packer @packer end |
#sources ⇒ Object (readonly)
Returns the value of attribute sources.
5 6 7 |
# File 'lib/sideload/config.rb', line 5 def sources @sources end |
#unpacker ⇒ Object (readonly)
Returns the value of attribute unpacker.
5 6 7 |
# File 'lib/sideload/config.rb', line 5 def unpacker @unpacker end |
Instance Method Details
#pack ⇒ Object
13 14 15 |
# File 'lib/sideload/config.rb', line 13 def pack @packer = Proc.new end |
#source(scope, arg, **config) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/sideload/config.rb', line 25 def source(scope, arg, **config) if !ALLOWED.include?(scope) raise "scope #{scope.inspect} not in #{ALLOWED.inspect}" end @sources << [ scope, arg, config, (block_given? ? Proc.new : nil) || @validate ] end |
#unpack ⇒ Object
17 18 19 |
# File 'lib/sideload/config.rb', line 17 def unpack @unpacker = Proc.new end |
#update! ⇒ Object
37 38 39 |
# File 'lib/sideload/config.rb', line 37 def update! Sideload.update!(@sources.dup, &(block_given? ? Proc.new : nil)) end |
#validate ⇒ Object
21 22 23 |
# File 'lib/sideload/config.rb', line 21 def validate @validate = Proc.new end |