Class: Mattermost::MattermostObject

Inherits:
Object
  • Object
show all
Defined in:
lib/mattermost/mattermost_object.rb

Overview

:nodoc: all

Direct Known Subclasses

Admin, Channel, Post, Team, User

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeMattermostObject



4
5
# File 'lib/mattermost/mattermost_object.rb', line 4

def initialize
end

Class Method Details

.find(id) ⇒ Object

Return the user that has an id of @param id



14
15
16
# File 'lib/mattermost/mattermost_object.rb', line 14

def self.find(id)
  find_by(:id => id)
end

.find_by(opts = {}) ⇒ Object

Return an object that matches a given attribute. Return nil if no matches



9
10
11
# File 'lib/mattermost/mattermost_object.rb', line 9

def self.find_by(opts = {})
  all.select { |obj| obj.send(opts.keys.first) == opts.values.first }.first
end

.method_missing(method_id, *args) ⇒ Object

:nodoc:



19
20
21
22
23
24
# File 'lib/mattermost/mattermost_object.rb', line 19

def method_missing(method_id, *args) #:nodoc:
  o = self.new
  o.send(method_id, *args)
rescue HTTParty::UnsupportedURIScheme
  raise "You must set Mattermost.connect before calling #{self.inspect}##{method_id}"
end