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
- #has_branch? ⇒ Boolean
-
#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.
32 33 34 35 |
# File 'lib/txgh/tx_branch_resource.rb', line 32 def initialize(resource, branch) @resource = resource @branch = branch end |
Instance Attribute Details
#branch ⇒ Object (readonly)
Returns the value of attribute branch.
12 13 14 |
# File 'lib/txgh/tx_branch_resource.rb', line 12 def branch @branch end |
#resource ⇒ Object (readonly)
Returns the value of attribute resource.
12 13 14 |
# File 'lib/txgh/tx_branch_resource.rb', line 12 def resource @resource end |
Class Method Details
.deslugify(resource_slug, branch) ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/txgh/tx_branch_resource.rb', line 21 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
15 16 17 18 19 |
# File 'lib/txgh/tx_branch_resource.rb', line 15 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
#has_branch? ⇒ Boolean
52 53 54 |
# File 'lib/txgh/tx_branch_resource.rb', line 52 def has_branch? true end |
#resource_slug ⇒ Object
37 38 39 |
# File 'lib/txgh/tx_branch_resource.rb', line 37 def resource_slug "#{resource.resource_slug}-#{slugified_branch}" end |
#slugs ⇒ Object
41 42 43 |
# File 'lib/txgh/tx_branch_resource.rb', line 41 def slugs [project_slug, resource_slug] end |
#to_h ⇒ Object
45 46 47 48 49 50 |
# File 'lib/txgh/tx_branch_resource.rb', line 45 def to_h resource.to_h.merge( project_slug: project_slug, resource_slug: resource_slug ) end |