Module: WithUsages

Extended by:
ActiveSupport::Concern
Included in:
Content
Defined in:
app/models/concerns/with_usages.rb

Instance Method Summary collapse

Instance Method Details

#usage_in_organization(organization = Organization.current) ⇒ Object



8
9
10
# File 'app/models/concerns/with_usages.rb', line 8

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



12
13
14
15
# File 'app/models/concerns/with_usages.rb', line 12

def usage_in_organization_of_type(type, organization = Organization.current)
  item = usage_in_organization(organization)
  item.is_a?(type) ? item : nil
end