Sha256: 1dad08e7f056837bf263a0e30786e897f5a63a38cd332d3df0481c2d7274f9b4

Contents?: true

Size: 761 Bytes

Versions: 5

Compression:

Stored size: 761 Bytes

Contents

module Githu3
  
  class Resource
      
    extend Githu3::Relations
    
    def initialize(d, client)
      @client = client
      
      if d.is_a?(String)
        @attributes = Githu3::Store.new(client.get(d).body)
      else
        @attributes = Githu3::Store.new(d)
      end
    end
    
    def id
      @attributes.id
    end
    
    def get *args
      @client.get(*args)
    end
    
    def _path
      return if url.nil?
      URI.parse(url).path
    end
    
    def method_missing m, *args
      val = @attributes.send(m, *args)
      time_val = Time.parse(val) if m =~ /_at$/ rescue nil
      time_val || val
    end
    
    def _attributes
      @attributes
    end
    
    protected
    
    def _client
      @client
    end
  
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
githu3-0.0.8 lib/githu3/resource.rb
githu3-0.0.7 lib/githu3/resource.rb
githu3-0.0.6 lib/githu3/resource.rb
githu3-0.0.5 lib/githu3/resource.rb
githu3-0.0.4 lib/githu3/resource.rb