Class: LocalAuthority
- Inherits:
-
Object
- Object
- LocalAuthority
- Includes:
- Mongoid::Document
- Defined in:
- app/models/local_authority.rb
Constant Summary collapse
- GOVSPEAK_FIELDS =
[]
Class Method Summary collapse
Instance Method Summary collapse
- #interactions_for(lgsl_code, lgil_code = nil) ⇒ Object
- #preferred_interaction_for(lgsl_code, lgil_code = nil) ⇒ Object
- #provides_service?(lgsl_code, lgil_code = nil) ⇒ Boolean
Class Method Details
.find_by_snac(snac) ⇒ Object
27 28 29 |
# File 'app/models/local_authority.rb', line 27 def self.find_by_snac(snac) for_snacs([snac]).first end |
Instance Method Details
#interactions_for(lgsl_code, lgil_code = nil) ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'app/models/local_authority.rb', line 35 def interactions_for(lgsl_code, lgil_code = nil) interactions = local_interactions.where(lgsl_code: lgsl_code) if lgil_code interactions.where(lgil_code: lgil_code) else interactions end end |
#preferred_interaction_for(lgsl_code, lgil_code = nil) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'app/models/local_authority.rb', line 44 def preferred_interaction_for(lgsl_code, lgil_code = nil) interactions = local_interactions.where(lgsl_code: lgsl_code) if lgil_code interactions.where(lgil_code: lgil_code).first else interactions.excludes( lgil_code: LocalInteraction::LGIL_CODE_PROVIDING_INFORMATION ).order_by([:lgil_code, :asc]).first || interactions.where( lgil_code: LocalInteraction::LGIL_CODE_PROVIDING_INFORMATION ).first end end |
#provides_service?(lgsl_code, lgil_code = nil) ⇒ Boolean
31 32 33 |
# File 'app/models/local_authority.rb', line 31 def provides_service?(lgsl_code, lgil_code = nil) interactions_for(lgsl_code, lgil_code).any? end |