class Dashbeautiful::Organization
description TODO
Constants
- ATTRIBUTES
Attributes
api[RW]
id[R]
name[R]
url[R]
Public Class Methods
all(api_key, api: API.new(api_key))
click to toggle source
# File lib/dashbeautiful/organization.rb, line 9 def self.all(api_key, api: API.new(api_key)) raise ArgumentError, 'api_key is nil. Either initialize Organization or pass a key' if api_key.nil? api.organizations.map { |org| Organization.new(api, **org) } end
find_by(attribute, value, api_key, api: API.new(api_key))
click to toggle source
# File lib/dashbeautiful/organization.rb, line 15 def self.find_by(attribute, value, api_key, api: API.new(api_key)) all(api_key, api: api).each do |org| return org if org.send(attribute) == value end nil end
init(organization:, api_key:, api: API.new(api_key))
click to toggle source
# File lib/dashbeautiful/organization.rb, line 22 def self.init(organization:, api_key:, api: API.new(api_key)) ATTRIBUTES.each do |attribute| org = find_by(attribute, organization, api_key, api: api) return org unless org.nil? end raise ArgumentError, "Could not find organization: #{organization}" end
new(api, **attributes)
click to toggle source
# File lib/dashbeautiful/organization.rb, line 30 def initialize(api, **attributes) @api = api @id = attributes[:id] @name = attributes[:name] @url = attributes[:url] end
Public Instance Methods
api_key()
click to toggle source
# File lib/dashbeautiful/organization.rb, line 42 def api_key api.key end
name=(value)
click to toggle source
# File lib/dashbeautiful/organization.rb, line 37 def name=(value) api.update_organization(id, name: value) @name = value end
networks()
click to toggle source
# File lib/dashbeautiful/organization.rb, line 46 def networks @networks ||= api.networks(id).map { |network| Network.create(self, **network) } end
networks!()
click to toggle source
# File lib/dashbeautiful/organization.rb, line 50 def networks! @networks = nil networks end