Created
February 11, 2015 19:09
-
-
Save moudy/e3aabd4ce2fa67637b82 to your computer and use it in GitHub Desktop.
This file contains 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
# 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