Class: OpenSesame::Github::Base
- Inherits:
-
Object
- Object
- OpenSesame::Github::Base
- Defined in:
- lib/opensesame/github/base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
Class Method Summary collapse
-
.lazy_attr_reader(*attrs) ⇒ Object
Public: Define readers from attributes hash.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #get(*args) ⇒ Object
-
#initialize(attributes = {}) {|_self| ... } ⇒ Base
constructor
Public: Instantiate a new Github::TeamMember from api attributes.
Constructor Details
#initialize(attributes = {}) {|_self| ... } ⇒ Base
Public: Instantiate a new Github::TeamMember from api attributes.
attributes - hash of api github team member attributes
Examples
Github::TeamMember.new(
"gravatar_id"=>"f009205a899da22248cca0b772aec9c9",
"url"=>"https://api.github.com/users/defunkt",
"avatar_url"=>"https://secure.gravatar.com/avatar/abcd1234.png",
"id"=>2,
"login"=>"defunkt"
)
# => <Github::TeamMember>
Returns new Github::TeamMember.
41 42 43 44 |
# File 'lib/opensesame/github/base.rb', line 41 def initialize(attributes = {}) @attributes = attributes yield self if block_given? end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
23 24 25 |
# File 'lib/opensesame/github/base.rb', line 23 def attributes @attributes end |
Class Method Details
.lazy_attr_reader(*attrs) ⇒ Object
Public: Define readers from attributes hash
symbol(s) - Method name
Examples
lazy_attr_reader :id, :login
13 14 15 16 17 18 19 20 21 |
# File 'lib/opensesame/github/base.rb', line 13 def self.lazy_attr_reader(*attrs) attrs.each do |attribute| class_eval do define_method(attribute) do @attributes[attribute.to_s] || @attributes[attribute] # allow string or symbol access end end end end |
Instance Method Details
#==(other) ⇒ Object
46 47 48 |
# File 'lib/opensesame/github/base.rb', line 46 def ==(other) super || (other.class == self.class && other.id == self.id) end |
#get(*args) ⇒ Object
50 51 52 |
# File 'lib/opensesame/github/base.rb', line 50 def get(*args) OpenSesame::Github.api.get(*args) end |