Class: Meibo::Organization

Inherits:
Object
  • Object
show all
Defined in:
lib/meibo/organization.rb

Direct Known Subclasses

JapanProfile::Organization

Constant Summary collapse

TYPES =
{
  department: "department",
  school: "school",
  district: "district",
  local: "local",
  state: "state",
  national: "national"
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(sourced_id:, name:, type:, status: nil, date_last_modified: nil, identifier: nil, parent_sourced_id: nil, **extension_fields) ⇒ Organization

Returns a new instance of Organization.



33
34
35
36
37
38
39
40
41
42
# File 'lib/meibo/organization.rb', line 33

def initialize(sourced_id:, name:, type:, status: nil, date_last_modified: nil, identifier: nil, parent_sourced_id: nil, **extension_fields)
  @sourced_id = sourced_id
  @status = status
  @date_last_modified = date_last_modified
  @name = name
  @type = type
  @identifier = identifier
  @parent_sourced_id = parent_sourced_id
  @extension_fields = extension_fields
end

Instance Method Details

#childrenObject



76
77
78
# File 'lib/meibo/organization.rb', line 76

def children
  collection.where(parent_sourced_id: sourced_id)
end

#classesObject



84
85
86
# File 'lib/meibo/organization.rb', line 84

def classes
  Meibo.current_roster.classes.where(school_sourced_id: sourced_id)
end

#collectionObject



44
45
46
# File 'lib/meibo/organization.rb', line 44

def collection
  Meibo.current_roster.organizations
end

#coursesObject



88
89
90
# File 'lib/meibo/organization.rb', line 88

def courses
  Meibo.current_roster.courses.where(org_sourced_id: sourced_id)
end

#department?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/meibo/organization.rb', line 48

def department?
  type == TYPES[:department]
end

#district?Boolean

Returns:

  • (Boolean)


56
57
58
# File 'lib/meibo/organization.rb', line 56

def district?
  type == TYPES[:district]
end

#enrollmentsObject



80
81
82
# File 'lib/meibo/organization.rb', line 80

def enrollments
  Meibo.current_roster.enrollments.where(school_sourced_id: sourced_id)
end

#local?Boolean

Returns:

  • (Boolean)


60
61
62
# File 'lib/meibo/organization.rb', line 60

def local?
  type == TYPES[:local]
end

#national?Boolean

Returns:

  • (Boolean)


68
69
70
# File 'lib/meibo/organization.rb', line 68

def national?
  type == TYPES[:national]
end

#parentObject



72
73
74
# File 'lib/meibo/organization.rb', line 72

def parent
  parent_sourced_id && collection.find(parent_sourced_id)
end

#rolesObject



92
93
94
# File 'lib/meibo/organization.rb', line 92

def roles
  Meibo.current_roster.roles.where(org_sourced_id: sourced_id)
end

#school?Boolean

Returns:

  • (Boolean)


52
53
54
# File 'lib/meibo/organization.rb', line 52

def school?
  type == TYPES[:school]
end

#state?Boolean

Returns:

  • (Boolean)


64
65
66
# File 'lib/meibo/organization.rb', line 64

def state?
  type == TYPES[:state]
end