class Troo::Remote::Persistence::Comment

Attributes

comment[R]
external_card_id[R]

Public Class Methods

new(external_card_id, comment) click to toggle source

@param [String] @param [] @return [Troo::Remote::Persistence::Comment]

# File lib/troo/remote/persistence/comment.rb, line 17
def initialize(external_card_id, comment)
  @external_card_id = external_card_id
  @comment          = comment
end
with(external_card_id, comment) click to toggle source

@param [String] @param [] @return []

# File lib/troo/remote/persistence/comment.rb, line 9
def with(external_card_id, comment)
  new(external_card_id, comment).create_local
end

Public Instance Methods

create_local() click to toggle source

@return []

# File lib/troo/remote/persistence/comment.rb, line 23
def create_local
  return Troo::Persistence::Local
    .with_collection(resource).first if any?
  false
end

Private Instance Methods

any?() click to toggle source
# File lib/troo/remote/persistence/comment.rb, line 33
def any?
  resource.any?
end
interpolation() click to toggle source
# File lib/troo/remote/persistence/comment.rb, line 51
def interpolation
  { external_id: external_card_id }
end
parameters() click to toggle source
# File lib/troo/remote/persistence/comment.rb, line 41
def parameters
  {
    verb:          :post,
    endpoint:      :create_comment,
    interpolation: interpolation,
    query:         query,
    model:         Remote::Comment
  }
end
query() click to toggle source
# File lib/troo/remote/persistence/comment.rb, line 55
def query
  { text: comment }
end
resource() click to toggle source
# File lib/troo/remote/persistence/comment.rb, line 37
def resource
  @resource ||= API::Client.perform(parameters)
end