Skip to content

Instantly share code, notes, and snippets.

@moudy
Created February 11, 2015 19:09
Show Gist options
  • Save moudy/e3aabd4ce2fa67637b82 to your computer and use it in GitHub Desktop.
Save moudy/e3aabd4ce2fa67637b82 to your computer and use it in GitHub Desktop.
# Usage
ProfileQuery.call(1)
# Object
class ProfileQuery
def self.call(options)
new(options).call
end
def initialize(profile_id)
@profile_id = options.fetch(:profile_id)
@include = options.fetch(:include)
end
def call
s = OpenStruct
s.profile = profile
s.files if include_files?
s
end
protected
def files
@files ||= profile.files
end
def profile
@profile ||= Profile.find(@profile_id)
end
def include_files?
@include.match(/files/)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment