-
Notifications
You must be signed in to change notification settings - Fork 135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expose repo license #106
Expose repo license #106
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One style request, but otherwise 👍 😍
# If not specified, defaults to the hash key | ||
# | ||
# Returns a symbol representing the instance method | ||
def self.def_hash_delegator(hash, key, method = nil) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The order of these is hard to read. I think this is easier to read:
def self.def_hash_delegator(method, hash, key)
Having the method name only some of the times is hard to grok.
I guess matching it with def_delegator
is a noble goal. In that case, I'd say we should always require the method
argument. Also, for 👀 sake, maybe align each argument in a table-like format for easy scanning?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call. Implemented via 211fe3d.
@jekyllbot: merge +minor |
A follow up to #105, this PR exposes the repository's licenses as
site.github.license
. I'd like to use this to conditionally expose an "This site is open source, help improve this page" link if a repo is public and has an open source license (versus public but not necessarily looking for contributions).In doing this, I realized that we had a handful of very similar methods on the Repository model that simply delegated to a hash. Forwardable can't delegate to
[]
, only to the method itself, so I created a quickdef_hash_delegator
helper, to allow us to DRY things up a bit and delegate a method more easily to a hash key. It works exactly likedef_delegator
, e.g.def_hash_delegator :repo_info, :license
is the same as:and
def_hash_delegator :repo_info, :description, :tagline
is the same as: