Class: FlashFlow::Data::Branch
- Inherits:
-
Object
- Object
- FlashFlow::Data::Branch
- Defined in:
- lib/flash_flow/data/branch.rb
Instance Attribute Summary collapse
-
#conflict_sha ⇒ Object
Returns the value of attribute conflict_sha.
-
#created_at ⇒ Object
Returns the value of attribute created_at.
-
#current_record ⇒ Object
Returns the value of attribute current_record.
-
#merge_order ⇒ Object
Returns the value of attribute merge_order.
-
#metadata ⇒ Object
Returns the value of attribute metadata.
-
#ref ⇒ Object
Returns the value of attribute ref.
-
#resolutions ⇒ Object
Returns the value of attribute resolutions.
-
#sha ⇒ Object
Returns the value of attribute sha.
-
#status ⇒ Object
Returns the value of attribute status.
-
#stories ⇒ Object
Returns the value of attribute stories.
-
#updated_at ⇒ Object
Returns the value of attribute updated_at.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
- #add_metadata(data) ⇒ Object
- #deleted! ⇒ Object
- #deleted? ⇒ Boolean
- #fail!(conflict_sha = nil) ⇒ Object
- #fail? ⇒ Boolean
-
#initialize(_ref) ⇒ Branch
constructor
A new instance of Branch.
- #merge(other) ⇒ Object
- #removed! ⇒ Object
- #removed? ⇒ Boolean
- #set_resolutions(_resolutions) ⇒ Object
- #success! ⇒ Object
- #success? ⇒ Boolean
- #to_hash ⇒ Object (also: #to_h)
- #to_json(_) ⇒ Object
- #unknown! ⇒ Object
- #unknown? ⇒ Boolean
Constructor Details
#initialize(_ref) ⇒ Branch
Returns a new instance of Branch.
11 12 13 14 15 16 17 18 |
# File 'lib/flash_flow/data/branch.rb', line 11 def initialize(_ref) @ref = _ref @resolutions = {} @stories = [] @metadata = {} @updated_at = Time.now @created_at = Time.now end |
Instance Attribute Details
#conflict_sha ⇒ Object
Returns the value of attribute conflict_sha.
8 9 10 |
# File 'lib/flash_flow/data/branch.rb', line 8 def conflict_sha @conflict_sha end |
#created_at ⇒ Object
Returns the value of attribute created_at.
8 9 10 |
# File 'lib/flash_flow/data/branch.rb', line 8 def created_at @created_at end |
#current_record ⇒ Object
Returns the value of attribute current_record.
8 9 10 |
# File 'lib/flash_flow/data/branch.rb', line 8 def current_record @current_record end |
#merge_order ⇒ Object
Returns the value of attribute merge_order.
8 9 10 |
# File 'lib/flash_flow/data/branch.rb', line 8 def merge_order @merge_order end |
#metadata ⇒ Object
Returns the value of attribute metadata.
8 9 10 |
# File 'lib/flash_flow/data/branch.rb', line 8 def @metadata end |
#ref ⇒ Object
Returns the value of attribute ref.
8 9 10 |
# File 'lib/flash_flow/data/branch.rb', line 8 def ref @ref end |
#resolutions ⇒ Object
Returns the value of attribute resolutions.
8 9 10 |
# File 'lib/flash_flow/data/branch.rb', line 8 def resolutions @resolutions end |
#sha ⇒ Object
Returns the value of attribute sha.
8 9 10 |
# File 'lib/flash_flow/data/branch.rb', line 8 def sha @sha end |
#status ⇒ Object
Returns the value of attribute status.
8 9 10 |
# File 'lib/flash_flow/data/branch.rb', line 8 def status @status end |
#stories ⇒ Object
Returns the value of attribute stories.
8 9 10 |
# File 'lib/flash_flow/data/branch.rb', line 8 def stories @stories end |
#updated_at ⇒ Object
Returns the value of attribute updated_at.
8 9 10 |
# File 'lib/flash_flow/data/branch.rb', line 8 def updated_at @updated_at end |
Class Method Details
.from_hash(hash) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/flash_flow/data/branch.rb', line 20 def self.from_hash(hash) branch = new(hash['ref']) branch.sha = hash['sha'] branch.status = hash['status'] branch.merge_order = hash['merge_order'] branch.resolutions = hash['resolutions'] branch.stories = hash['stories'] branch. = hash['metadata'] branch.conflict_sha = hash['conflict_sha'] || hash['metadata'].to_h['conflict_sha'] branch.updated_at = TimeHelper.massage_time(hash['updated_at']) branch.created_at = TimeHelper.massage_time(hash['created_at']) branch end |
Instance Method Details
#==(other) ⇒ Object
34 35 36 |
# File 'lib/flash_flow/data/branch.rb', line 34 def ==(other) other.ref == ref end |
#add_metadata(data) ⇒ Object
72 73 74 75 |
# File 'lib/flash_flow/data/branch.rb', line 72 def (data) self. ||= {} self..merge!(data) end |
#deleted! ⇒ Object
106 107 108 |
# File 'lib/flash_flow/data/branch.rb', line 106 def deleted! self.status = 'deleted' end |
#deleted? ⇒ Boolean
110 111 112 |
# File 'lib/flash_flow/data/branch.rb', line 110 def deleted? self.status == 'deleted' end |
#fail!(conflict_sha = nil) ⇒ Object
89 90 91 92 |
# File 'lib/flash_flow/data/branch.rb', line 89 def fail!(conflict_sha=nil) self.conflict_sha = conflict_sha self.status = 'fail' end |
#fail? ⇒ Boolean
94 95 96 |
# File 'lib/flash_flow/data/branch.rb', line 94 def fail? self.status == 'fail' end |
#merge(other) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/flash_flow/data/branch.rb', line 58 def merge(other) unless other.nil? self.sha = other.sha self.status = other.status self.merge_order = other.merge_order self.resolutions = other.resolutions self.stories = self.stories.to_a | other.stories.to_a self.updated_at = Time.now self.created_at = [(self.created_at || Time.now), (other.created_at || Time.now)].min end self end |
#removed! ⇒ Object
98 99 100 |
# File 'lib/flash_flow/data/branch.rb', line 98 def removed! self.status = 'removed' end |
#removed? ⇒ Boolean
102 103 104 |
# File 'lib/flash_flow/data/branch.rb', line 102 def removed? self.status == 'removed' end |
#set_resolutions(_resolutions) ⇒ Object
77 78 79 |
# File 'lib/flash_flow/data/branch.rb', line 77 def set_resolutions(_resolutions) self.resolutions = _resolutions end |
#success! ⇒ Object
81 82 83 |
# File 'lib/flash_flow/data/branch.rb', line 81 def success! self.status = 'success' end |
#success? ⇒ Boolean
85 86 87 |
# File 'lib/flash_flow/data/branch.rb', line 85 def success? self.status == 'success' end |
#to_hash ⇒ Object Also known as: to_h
38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/flash_flow/data/branch.rb', line 38 def to_hash { 'ref' => ref, 'sha' => sha, 'status' => status, 'merge_order' => merge_order, 'resolutions' => resolutions, 'stories' => stories, 'conflict_sha' => conflict_sha, 'metadata' => , 'updated_at' => updated_at, 'created_at' => created_at, } end |
#to_json(_) ⇒ Object
54 55 56 |
# File 'lib/flash_flow/data/branch.rb', line 54 def to_json(_) JSON.pretty_generate(to_hash) end |
#unknown! ⇒ Object
114 115 116 |
# File 'lib/flash_flow/data/branch.rb', line 114 def unknown! self.status = nil end |
#unknown? ⇒ Boolean
118 119 120 |
# File 'lib/flash_flow/data/branch.rb', line 118 def unknown? self.status.nil? end |