Class: Jekyll::GitHubMetadata::Owner
- Inherits:
-
Object
- Object
- Jekyll::GitHubMetadata::Owner
- Extended by:
- Forwardable
- Defined in:
- lib/jekyll-github-metadata/owner.rb
Instance Attribute Summary collapse
-
#owner_login ⇒ Object
readonly
Returns the value of attribute owner_login.
Class Method Summary collapse
- .content_methods ⇒ Object
-
.def_hash_delegators(hash, *methods) ⇒ Object
Defines an instance method that delegates to a hash’s key.
Instance Method Summary collapse
-
#initialize(owner_login) ⇒ Owner
constructor
A new instance of Owner.
- #to_h ⇒ Object (also: #to_hash)
Constructor Details
#initialize(owner_login) ⇒ Owner
Returns a new instance of Owner.
61 62 63 |
# File 'lib/jekyll-github-metadata/owner.rb', line 61 def initialize(owner_login) @owner_login = owner_login end |
Instance Attribute Details
#owner_login ⇒ Object (readonly)
Returns the value of attribute owner_login.
59 60 61 |
# File 'lib/jekyll-github-metadata/owner.rb', line 59 def owner_login @owner_login end |
Class Method Details
.content_methods ⇒ Object
26 27 28 |
# File 'lib/jekyll-github-metadata/owner.rb', line 26 def self.content_methods @content_methods ||= [] end |
.def_hash_delegators(hash, *methods) ⇒ Object
Defines an instance method that delegates to a hash’s key
hash - a symbol representing the instance method to delegate to. The
instance method should return a hash or respond to #[]
key - the key to call within the hash method - (optional) the instance method the key should be aliased to.
If not specified, defaults to the hash key
Returns a symbol representing the instance method
17 18 19 20 21 22 23 24 |
# File 'lib/jekyll-github-metadata/owner.rb', line 17 def self.def_hash_delegators(hash, *methods) content_methods.concat(methods) methods.each do |method| define_method(method) do send(hash)[method.to_s] end end end |
Instance Method Details
#to_h ⇒ Object Also known as: to_hash
65 66 67 68 |
# File 'lib/jekyll-github-metadata/owner.rb', line 65 def to_h @to_h ||= self.class.content_methods .each_with_object({}) { |method, hash| hash[method.to_s] = public_send(method) } end |