class FlashFlow::Data::Branch
Attributes
conflict_sha[RW]
created_at[RW]
current_record[RW]
merge_order[RW]
metadata[RW]
ref[RW]
resolutions[RW]
sha[RW]
status[RW]
stories[RW]
updated_at[RW]
Public Class Methods
from_hash(hash)
click to toggle source
# 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.metadata = 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
new(_ref)
click to toggle source
# 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
Public Instance Methods
==(other)
click to toggle source
# File lib/flash_flow/data/branch.rb, line 34 def ==(other) other.ref == ref end
add_metadata(data)
click to toggle source
# File lib/flash_flow/data/branch.rb, line 72 def add_metadata(data) self.metadata ||= {} self.metadata.merge!(data) end
deleted!()
click to toggle source
# File lib/flash_flow/data/branch.rb, line 106 def deleted! self.status = 'deleted' end
deleted?()
click to toggle source
# File lib/flash_flow/data/branch.rb, line 110 def deleted? self.status == 'deleted' end
fail!(conflict_sha=nil)
click to toggle source
# File lib/flash_flow/data/branch.rb, line 89 def fail!(conflict_sha=nil) self.conflict_sha = conflict_sha self.status = 'fail' end
fail?()
click to toggle source
# File lib/flash_flow/data/branch.rb, line 94 def fail? self.status == 'fail' end
merge(other)
click to toggle source
# 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!()
click to toggle source
# File lib/flash_flow/data/branch.rb, line 98 def removed! self.status = 'removed' end
removed?()
click to toggle source
# File lib/flash_flow/data/branch.rb, line 102 def removed? self.status == 'removed' end
set_resolutions(_resolutions)
click to toggle source
# File lib/flash_flow/data/branch.rb, line 77 def set_resolutions(_resolutions) self.resolutions = _resolutions end
success!()
click to toggle source
# File lib/flash_flow/data/branch.rb, line 81 def success! self.status = 'success' end
success?()
click to toggle source
# File lib/flash_flow/data/branch.rb, line 85 def success? self.status == 'success' end
to_hash()
click to toggle source
# 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' => metadata, 'updated_at' => updated_at, 'created_at' => created_at, } end
Also aliased as: to_h
to_json(_)
click to toggle source
# File lib/flash_flow/data/branch.rb, line 54 def to_json(_) JSON.pretty_generate(to_hash) end
unknown!()
click to toggle source
# File lib/flash_flow/data/branch.rb, line 114 def unknown! self.status = nil end
unknown?()
click to toggle source
# File lib/flash_flow/data/branch.rb, line 118 def unknown? self.status.nil? end