Class: Txgh::Config::TxConfig
- Inherits:
-
Object
- Object
- Txgh::Config::TxConfig
- Defined in:
- lib/txgh/config/tx_config.rb
Instance Attribute Summary collapse
-
#lang_map ⇒ Object
readonly
Returns the value of attribute lang_map.
-
#resources ⇒ Object
readonly
Returns the value of attribute resources.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(resources, lang_map) ⇒ TxConfig
constructor
A new instance of TxConfig.
- #resource(slug, branch = nil) ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(resources, lang_map) ⇒ TxConfig
Returns a new instance of TxConfig.
61 62 63 64 |
# File 'lib/txgh/config/tx_config.rb', line 61 def initialize(resources, lang_map) @resources = resources @lang_map = lang_map end |
Instance Attribute Details
#lang_map ⇒ Object (readonly)
Returns the value of attribute lang_map.
59 60 61 |
# File 'lib/txgh/config/tx_config.rb', line 59 def lang_map @lang_map end |
#resources ⇒ Object (readonly)
Returns the value of attribute resources.
59 60 61 |
# File 'lib/txgh/config/tx_config.rb', line 59 def resources @resources end |
Class Method Details
.load(contents) ⇒ Object
10 11 12 13 |
# File 'lib/txgh/config/tx_config.rb', line 10 def load(contents) config = Txgh::ParseConfig.load(contents) load_config(config) end |
.load_file(path) ⇒ Object
5 6 7 8 |
# File 'lib/txgh/config/tx_config.rb', line 5 def load_file(path) config = Txgh::ParseConfig.load_file(path) load_config(config) end |
Instance Method Details
#resource(slug, branch = nil) ⇒ Object
66 67 68 69 70 71 72 73 74 |
# File 'lib/txgh/config/tx_config.rb', line 66 def resource(slug, branch = nil) if branch TxBranchResource.find(self, slug, branch) else resources.find do |resource| resource.resource_slug == slug end end end |
#to_h ⇒ Object
76 77 78 |
# File 'lib/txgh/config/tx_config.rb', line 76 def to_h { resources: resources.map(&:to_h), lang_map: lang_map } end |