Class: Afterlife::Repo::Config
- Inherits:
-
Object
- Object
- Afterlife::Repo::Config
- Defined in:
- lib/afterlife/repo/config.rb
Overview
Reads configuration from the repo, either from YML or from the repo instance methods
Defined Under Namespace
Classes: Error
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(path) ⇒ Config
constructor
A new instance of Config.
- #read ⇒ Object
Constructor Details
#initialize(path) ⇒ Config
Returns a new instance of Config.
16 17 18 |
# File 'lib/afterlife/repo/config.rb', line 16 def initialize(path) @path = path end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
10 11 12 |
# File 'lib/afterlife/repo/config.rb', line 10 def path @path end |
Class Method Details
.read(path) ⇒ Object
12 13 14 |
# File 'lib/afterlife/repo/config.rb', line 12 def self.read(path, &) new(path).read(&) end |
Instance Method Details
#read ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/afterlife/repo/config.rb', line 20 def read(&) case from_yml when Hash yield(JSON.generate(from_yml)) when Array from_yml.each(&) when String, Symbol yield(from_yml) else fail Error, "No config with path '#{path}'" unless repo_method? yield(repo.public_send(repo_method)) end end |