Class: Trello::Action

Inherits:
BasicData show all
Defined in:
lib/trello/action.rb

Overview

Action represents some event that occurred. For instance, when a card is created.

Instance Attribute Summary

Attributes inherited from BasicData

#client

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BasicData

#==, client, create, #initialize, many, one, parse, parse_many, path_name, #refresh!, register_attributes, save

Constructor Details

This class inherits a constructor from Trello::BasicData

Class Method Details

.find(id, params = {}) ⇒ Object

Locate a specific action and return a new Action object.



10
11
12
# File 'lib/trello/action.rb', line 10

def find(id, params = {})
  client.find(:action, id, params)
end

.search(query, opts = {}) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/trello/action.rb', line 14

def search(query, opts={})
  response = client.get("/search/", { query: query }.merge(opts))
  formatted_response = JSON.parse(response).except("options").inject({}) do |res, key|
    res.merge!({ key.first => key.last.jsoned_into("Trello::#{key.first.singularize.capitalize}".constantize) })
    res
  end
end

Instance Method Details

#boardObject

Returns the board this action occurred on.



38
39
40
# File 'lib/trello/action.rb', line 38

def board
  client.get("/actions/#{id}/board").json_into(Board)
end

#cardObject

Returns the card the action occurred on.



43
44
45
# File 'lib/trello/action.rb', line 43

def card
  client.get("/actions/#{id}/card").json_into(Card)
end

#listObject

Returns the list the action occurred on.



48
49
50
# File 'lib/trello/action.rb', line 48

def list
  client.get("/actions/#{id}/list").json_into(List)
end

#update_fields(fields) ⇒ Object

Update the attributes of an action

Supply a hash of string keyed data retrieved from the Trello API representing an Action.



27
28
29
30
31
32
33
34
35
# File 'lib/trello/action.rb', line 27

def update_fields(fields)
  attributes[:id]                 = fields['id']
  attributes[:type]               = fields['type']
  attributes[:data]               = fields['data']
  attributes[:date]               = Time.iso8601(fields['date'])
  attributes[:member_creator_id]  = fields['idMemberCreator']
  attributes[:member_participant] = fields['member']
  self
end