Class: Company::Business

Inherits:
Resource show all
Defined in:
lib/company/resources/business.rb

Overview

Who the account belongs to: the one business behind a set of credentials.

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Resource

#id, #initialize, keys, node_keys

Constructor Details

This class inherits a constructor from Company::Resource

Class Method Details

.attributes ⇒ Object

What every business reads, by the vocabulary's names.



5
# File 'lib/company/resources/business.rb', line 5

def self.attributes = %i[id name phone]

Instance Method Details

#name ⇒ String

Returns business name.

Returns:

  • (String) —

    business name.



8
# File 'lib/company/resources/business.rb', line 8

def name = attribute :name

#phone ⇒ String?

Returns ten digits the business is reached on, nil where none can be dialed.

Returns:

  • (String, nil) —

    ten digits the business is reached on, nil where none can be dialed.



11
# File 'lib/company/resources/business.rb', line 11

def phone = Phone.from attribute(:phone)

#subsidiaries ⇒ Array<Business>

Itself first, then every business under it at any depth, in the order the platform lists them: a business on its own is its own one subsidiary, and a franchise reads flat. A gem whose platform nests businesses answers the ones directly under this one from the private below; the rest inherit none.

Returns:

  • (Array<Business>) —

    businesses an account may act as, this one included.



18
# File 'lib/company/resources/business.rb', line 18

def subsidiaries = [ self, *below.flat_map(&:subsidiaries) ]