Created
January 15, 2016 11:24
-
-
Save maxehmookau/113f6ed83e200cc5323e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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