Class: SuperSource::Organization
- Inherits:
-
Object
- Object
- SuperSource::Organization
- Defined in:
- lib/super_source/organization.rb
Constant Summary collapse
- @@current_organization =
nil
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
Class Method Summary collapse
- .current_organization ⇒ Object
- .current_organization_filename ⇒ Object
- .current_organization_from_file ⇒ Object
Instance Method Summary collapse
-
#initialize(name, id) ⇒ Organization
constructor
A new instance of Organization.
Constructor Details
#initialize(name, id) ⇒ Organization
Returns a new instance of Organization.
9 10 11 12 |
# File 'lib/super_source/organization.rb', line 9 def initialize(name, id) @name = name @id = id end |
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
5 6 7 |
# File 'lib/super_source/organization.rb', line 5 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/super_source/organization.rb', line 5 def name @name end |
Class Method Details
.current_organization ⇒ Object
34 35 36 |
# File 'lib/super_source/organization.rb', line 34 def self.current_organization @@current_organization ||= Organization.current_organization_from_file end |
.current_organization_filename ⇒ Object
14 15 16 |
# File 'lib/super_source/organization.rb', line 14 def self.current_organization_filename "#{ SuperSource.project_supso_config_root }/current_organization.json" end |
.current_organization_from_file ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/super_source/organization.rb', line 18 def self.current_organization_from_file organization_data = {} begin organization_data = JSON.parse(File.read(Organization.current_organization_filename)) organization_data = {} if !organization_data.is_a?(Object) rescue organization_data = {} end if organization_data['id'] Organization.new(organization_data['name'], organization_data['id']) else nil end end |