Sha256: 13d0953c2f277a4c00fcc400d52cd7afe30f3a87efbea7a83d6dae95b6e0837f

Contents?: true

Size: 688 Bytes

Versions: 1

Compression:

Stored size: 688 Bytes

Contents

# encoding: utf-8

module Crunchbase::Model
  class Membership < Crunchbase::Model::Organization

    RESOURCE_LIST = 'memberships'

    attr_reader :object

    def initialize(json)
      set_relationship_object('object', Crunchbase::Model::Person, json) if json['type'] == 'Person'
      set_relationship_object('object', Crunchbase::Model::Organization, json) if json['type'] == 'Organization'
    end

    def set_relationship_object(key, object_name, json)
      instance_variable_set "@#{key}", ( object_name.new(json) || nil )
    end

    def person?
      (object.type_name == "Person")
    end

    def organization?
      (object.type_name == "Organization")
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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