module HaveAPI::Resources::ActionState::Mixin

Public Instance Methods

state_to_hash(state) click to toggle source
# File lib/haveapi/resources/action_state.rb, line 27
def state_to_hash(state)
  hash = {
    id: state.id,
    label: state.label,
    status: state.status,
    created_at: state.created_at,
    updated_at: state.updated_at,
    can_cancel: state.can_cancel?
  }

  hash[:finished] = state.finished?

  progress = state.progress
  hash[:current] = progress[:current] || 0
  hash[:total] = progress[:total] || 0
  hash[:unit] = progress[:unit]

  hash
end