class Trello::Action
Action
represents some event that occurred. For instance, when a card is created.
@!attribute [r] id
@return [String]
@!attribute [r] type
@return [String]
@!attribute [r] data
@return [Hash]
@!attribute [r] date
@return [Datetime]
@!attribute [r] member_creator_id
@return [String]
@!attribute [r] member_participant
@return [Object]
Public Class Methods
find(id, params = {})
click to toggle source
Locate a specific action and return a new Action
object.
# File lib/trello/action.rb, line 23 def find(id, params = {}) client.find(:action, id, params) end
search(query, opts = {})
click to toggle source
# File lib/trello/action.rb, line 27 def search(query, opts = {}) response = client.get("/search/", { query: query }.merge(opts)) parse_json(response).except("options").each_with_object({}) do |(key, data), result| klass = "Trello::#{key.singularize.capitalize}".constantize result[key] = klass.from_json(data) end end
Public Instance Methods
board()
click to toggle source
Returns the board this action occurred on.
# File lib/trello/action.rb, line 51 def board Board.from_response client.get("/actions/#{id}/board") end
card()
click to toggle source
Returns the card the action occurred on.
# File lib/trello/action.rb, line 56 def card Card.from_response client.get("/actions/#{id}/card") end
list()
click to toggle source
Returns the list the action occurred on.
# File lib/trello/action.rb, line 61 def list List.from_response client.get("/actions/#{id}/list") end
update_fields(fields)
click to toggle source
Update the attributes of an action
Supply a hash of string keyed data retrieved from the Trello
API representing an Action
.
# File lib/trello/action.rb, line 40 def update_fields(fields) attributes[:id] = fields['id'] || attributes[:id] attributes[:type] = fields['type'] || attributes[:type] attributes[:data] = fields['data'] || attributes[:data] attributes[:date] = Time.iso8601(fields['date']) rescue nil if fields.has_key?('date') attributes[:member_creator_id] = fields['idMemberCreator'] || attributes[:member_creator_id] attributes[:member_participant] = fields['member'] || attributes[:member_participant] self end