Module: WithUsages
- Extended by:
- ActiveSupport::Concern
- Included in:
- Content
- Defined in:
- app/models/concerns/with_usages.rb
Instance Method Summary collapse
- #content_used_in?(organization) ⇒ Boolean
- #navigable_content_in(organization = Organization.current) ⇒ Object
- #usage_in_organization(organization = Organization.current) ⇒ Object
- #usage_in_organization_of_type(type, organization = Organization.current) ⇒ Object
- #used_in?(organization) ⇒ Boolean
Instance Method Details
#content_used_in?(organization) ⇒ Boolean
23 24 25 |
# File 'app/models/concerns/with_usages.rb', line 23 def content_used_in?(organization) navigable_content_in(organization).present? end |
#navigable_content_in(organization = Organization.current) ⇒ Object
19 20 21 |
# File 'app/models/concerns/with_usages.rb', line 19 def navigable_content_in(organization = Organization.current) self if used_in?(organization) end |
#usage_in_organization(organization = Organization.current) ⇒ Object
10 11 12 |
# File 'app/models/concerns/with_usages.rb', line 10 def usage_in_organization(organization = Organization.current) usages_in_organization(organization).first.try(:parent_item) end |
#usage_in_organization_of_type(type, organization = Organization.current) ⇒ Object
14 15 16 17 |
# File 'app/models/concerns/with_usages.rb', line 14 def usage_in_organization_of_type(type, organization = Organization.current) item = usage_in_organization(organization) item.is_a?(type) ? item : nil end |
#used_in?(organization) ⇒ Boolean
27 28 29 |
# File 'app/models/concerns/with_usages.rb', line 27 def used_in?(organization) usage_in_organization(organization).present? end |