Sha256: 946eb9a53fe86794ac9b4049080524eeddd384854cb26b3788bf2aef7fd4e7a9
Contents?: true
Size: 1.34 KB
Versions: 3
Compression:
Stored size: 1.34 KB
Contents
# encoding: utf-8 require "octokit" module OpenSesame class Member def self.organization_name OpenSesame.organization_name end def self.find(member_id) return nil unless member_id.present? attributes = organization_members.detect { |member| member.id.to_s == member_id.to_s } return nil unless attributes.present? new(attributes) end def self.organization_members github_api.organization_members(organization_name) end def self.github_api @github_api ||= Octokit.new end 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 def self.serialize_into_session(member) [member.id] end def self.serialize_from_session(*args) id = args.shift find(id) end attr_accessor :attributes lazy_attr_reader :id, :login, :avatar_url, :gravatar_id, :url def initialize(attributes = {}) @attributes = attributes end def id @attributes["id"] end def organization_name self.class.organization_name end def ==(other) super || (other.class == self.class && other.id == self.id) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
opensesame-0.1.2 | lib/open_sesame/member.rb |
opensesame-0.1.1 | lib/open_sesame/member.rb |
opensesame-0.1.0 | lib/open_sesame/member.rb |