Class: Malartu::Portfolio

Inherits:
MalartuObject show all
Defined in:
lib/malartu/portfolio.rb

Overview

A portfolio is how groups track companies within Malartu

Instance Attribute Summary collapse

Attributes inherited from MalartuObject

#json

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from MalartuObject

paginate?

Constructor Details

#initialize(json) ⇒ Portfolio

Returns a new instance of Portfolio.



5
6
7
8
9
10
11
12
13
# File 'lib/malartu/portfolio.rb', line 5

def initialize(json)
  super
  define_singleton_method('connections') do
    json['connections'].map do |c|
      Malartu::Connection.new(c)
    end
  end if json['connections']
  define_singleton_method('path') { json['path'] || "/v0/kpi/portfolios/#{sid}" }
end

Instance Attribute Details

#connectionsObject

Returns the value of attribute connections.



4
5
6
# File 'lib/malartu/portfolio.rb', line 4

def connections
  @connections
end

#pathObject

Returns the value of attribute path.



4
5
6
# File 'lib/malartu/portfolio.rb', line 4

def path
  @path
end

Class Method Details

.find(sid) ⇒ Object



15
16
17
18
# File 'lib/malartu/portfolio.rb', line 15

def self.find(sid)
  res = Malartu.request('get', "/kpi/portfolios/#{sid}")
  Malartu::Portfolio.new(res)
end

.listObject



20
21
22
23
24
25
# File 'lib/malartu/portfolio.rb', line 20

def self.list
  res = Malartu.request('get', '/kpi/portfolios')
  res['portfolios'].map do |schedule|
    Malartu::Portfolio.new(schedule)
  end
end