Sha256: b7509f46ca4976422c7192c9966ca5ae4dd049925aa967c1ea4aac9e8f2b0896
Contents?: true
Size: 1.1 KB
Versions: 1
Compression:
Stored size: 1.1 KB
Contents
module PGit module Pivotal class IndividualRequest < Pivotal::Request def initialize(&block) yield self if block_given? end def put! `curl -X PUT -H 'X-TrackerToken: #{api_token}' -H 'Content-Type: application/json' -d '#{JSON.generate(to_hash)}' #{link}` @changed_attributes = [] end def get! define_methods get_request end def define_methods(json) JSON.parse(json).each do |key, value| instance_variable_set("@#{key}", value) end end def to_hash @changed_attributes.inject(Hash.new) {|accum, key| accum[key] = send(key); accum } end def hash=(hash) hash.each do |key, value| if key == 'stories' define_singleton_method key do value.map do |story_hash| PGit::Pivotal::Story.new do |s| s.hash = story_hash end end end else define_singleton_method key do value end end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
pgit-1.0.0 | lib/pgit/pivotal/individual_request.rb |