Sha256: 58c1fccdb15f0408f0c76c3aa9d0040d27a71080b56e35a74ec813f694f9cb3c

Contents?: true

Size: 1006 Bytes

Versions: 1

Compression:

Stored size: 1006 Bytes

Contents

# encoding: utf-8

module Crunchbase::Model
  class Job < Crunchbase::Model::Entity
    
    RESOURCE_LIST = 'jobs'

    attr_reader :title, :started_on, :started_on_trust_code, :ended_on, :ended_on_trust_code, 
                :created_at, :updated_at

    attr_reader :person, :organization

    def initialize(json)
      super

      unless (relationships = json['relationships']).nil?
        set_relationships_object(Crunchbase::Model::Person, 'person', relationships['person'])
        set_relationships_object(Crunchbase::Model::Organization, 'organization', relationships['organization'])
      end
    end
    
    def property_keys
      %w[
        title started_on started_on_trust_code ended_on ended_on_trust_code created_at updated_at
      ]
    end

    def date_keys
      %w[ started_on ended_on ]
    end

    def set_relationships_object(object_name, key, item)
      return unless item
      
      instance_variable_set "@#{key}", ( object_name.new(item) || nil )
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
crunchbase-ruby-library-0.0.1 lib/crunchbase/model/job.rb