Skip to content

Instantly share code, notes, and snippets.

@maxehmookau
Created January 15, 2016 11:24
Show Gist options
  • Save maxehmookau/113f6ed83e200cc5323e to your computer and use it in GitHub Desktop.
Save maxehmookau/113f6ed83e200cc5323e to your computer and use it in GitHub Desktop.
class HierarchyProcessor
attr_reader :input, :user
def initialize(input, user)
raise ArgumentError, "user expected User, was #{ user.class }" unless user.is_a?(User)
@input = JSON.parse(input)
@user = user
end
def service_groups
ServiceGroup.where(id: @input['service_groups'].map{ |s| s['id'] })
end
def locations
Location.where(id: @input['locations'].map{ |s| s['id'] })
end
def roles
Role.where(id: @input['roles'].map{ |s| s['id'] })
end
def employment_types
EmploymentType.where(id: @input['employment_types'].map{ |s| s['id'] })
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment