Sha256: db6a32b94a78a936331b71b4f3b6d018b5640f29b1b2816f0c0e5782bb4d0492
Contents?: true
Size: 1.08 KB
Versions: 1
Compression:
Stored size: 1.08 KB
Contents
module IntercomRails module Proxy class Company < Proxy def self.companies_for_user(user) return unless config(:user).company_association.present? companies = config(:user).company_association.call(user.user) return unless companies.kind_of?(Array) companies.map { |company| new(company) }.select { |company_proxy| company_proxy.valid? } end 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? && 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.3 | lib/intercom-rails/proxy/company.rb |