Sha256: 4fa31d6b4058e99b3747c10c965670439c452fda1f6f07b395ba5081b53a4bf1

Contents?: true

Size: 682 Bytes

Versions: 1

Compression:

Stored size: 682 Bytes

Contents

module IntercomRails

  module Proxy

    class Company < Proxy

      proxy_delegator :id, :identity => true
      proxy_delegator :name
      proxy_delegator :created_at

      config_delegator :plan
      config_delegator :monthly_spend

      def self.current_in_context(search_object)
        begin
          if config.current.present?
            company_proxy = new(search_object.instance_eval(&config.current), search_object)
            return company_proxy if company_proxy.valid?
          end
        rescue NameError
        end

        raise NoCompanyFoundError
      end

      def valid?
        company.present? && identity_present?
      end

    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
intercom-rails-0.3.2 lib/intercom-rails/proxy/company.rb