Class: CiviCrm::FinancialType
- Inherits:
-
BaseResource
- Object
- Resource
- BaseResource
- CiviCrm::FinancialType
- Defined in:
- lib/civicrm/resources/financial_type.rb
Constant Summary collapse
- @@_financial_type_cache =
{}
Class Method Summary collapse
Methods included from Actions::Destroy
Methods included from Actions::Update
Methods included from Actions::Create
Methods included from Actions::Find
Methods included from Actions::List
Methods inherited from Resource
#as_json, #attribute, #attributes, build_from, entity, entity_class_name, #initialize, #inspect, #method_missing, #refresh_from, #to_hash, #to_json, #to_s
Constructor Details
This class inherits a constructor from CiviCrm::Resource
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class CiviCrm::Resource
Class Method Details
.[](name, cache: true, create: Rails.env.development?) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/civicrm/resources/financial_type.rb', line 7 def self.[](name, cache: true, create: Rails.env.development?) cache_key = name if cache && @@_financial_type_cache.key?(cache_key) return @@_financial_type_cache[cache_key] end type = find_by("name" => name) type ||= create(name: name) if create if type @@_financial_type_cache[cache_key] = type.id if cache return type.id end raise Errors::NotFound.new( "FinancialType with name=#{name}" ) end |