Class: Txgh::TxBranchResource
- Inherits:
-
Object
- Object
- Txgh::TxBranchResource
- Extended by:
- Forwardable
- Defined in:
- lib/txgh/tx_branch_resource.rb
Instance Attribute Summary collapse
-
#branch ⇒ Object
readonly
Returns the value of attribute branch.
-
#resource ⇒ Object
readonly
Returns the value of attribute resource.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(resource, branch) ⇒ TxBranchResource
constructor
A new instance of TxBranchResource.
- #resource_slug ⇒ Object
- #slugs ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(resource, branch) ⇒ TxBranchResource
Returns a new instance of TxBranchResource.
33 34 35 36 |
# File 'lib/txgh/tx_branch_resource.rb', line 33 def initialize(resource, branch) @resource = resource @branch = branch end |
Instance Attribute Details
#branch ⇒ Object (readonly)
Returns the value of attribute branch.
13 14 15 |
# File 'lib/txgh/tx_branch_resource.rb', line 13 def branch @branch end |
#resource ⇒ Object (readonly)
Returns the value of attribute resource.
13 14 15 |
# File 'lib/txgh/tx_branch_resource.rb', line 13 def resource @resource end |
Class Method Details
.deslugify(resource_slug, branch) ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/txgh/tx_branch_resource.rb', line 22 def deslugify(resource_slug, branch) suffix = "-#{Utils.slugify(branch)}" if resource_slug.end_with?(suffix) resource_slug.chomp(suffix) else resource_slug end end |
.find(tx_config, resource_slug, branch) ⇒ Object
16 17 18 19 20 |
# File 'lib/txgh/tx_branch_resource.rb', line 16 def find(tx_config, resource_slug, branch) resource_slug = deslugify(resource_slug, branch) resource = tx_config.resource(resource_slug) new(resource, branch) if resource end |
Instance Method Details
#resource_slug ⇒ Object
38 39 40 |
# File 'lib/txgh/tx_branch_resource.rb', line 38 def resource_slug "#{resource.resource_slug}-#{slugified_branch}" end |
#slugs ⇒ Object
42 43 44 |
# File 'lib/txgh/tx_branch_resource.rb', line 42 def slugs [project_slug, resource_slug] end |
#to_h ⇒ Object
46 47 48 49 50 51 |
# File 'lib/txgh/tx_branch_resource.rb', line 46 def to_h resource.to_h.merge( project_slug: project_slug, resource_slug: resource_slug ) end |