Sha256: 956a345dd06ba3709547dc730e389ef970f0816bf4f07467f354083bba8af230

Contents?: true

Size: 758 Bytes

Versions: 1

Compression:

Stored size: 758 Bytes

Contents

module IntercomRails

  module Proxy

    class Company < Proxy

      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.respond_to?(:id) && company.id.present?
      end

      def standard_data
        hsh = {}
        hsh[:id] = company.id
        hsh[:name] = company.name if attribute_present?(:name) 
        hsh[:created_at] = company.created_at if attribute_present?(:created_at) 
        hsh
      end

    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

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