Sha256: f5f405e4defb1498c88116c66b4fdbbdecf78d584080f9d51367c50f87ba2c4a

Contents?: true

Size: 1.66 KB

Versions: 14

Compression:

Stored size: 1.66 KB

Contents

module Mumuki::Domain::Helpers::Organization
  extend ActiveSupport::Concern
  include Mumukit::Platform::Notifiable

  included do
    delegate *Mumuki::Domain::Organization::Theme.accessors, to: :theme
    delegate *Mumuki::Domain::Organization::Settings.accessors, :private?, :login_settings, :in_preparation?, :disabled?, to: :settings
    delegate *Mumuki::Domain::Organization::Profile.accessors, :locale_json, to: :profile
  end

  def platform_class_name
    :Organization
  end

  def slug
    Mumukit::Auth::Slug.join_s name
  end

  def central?
    name == 'central'
  end

  def test?
    name == 'test'
  end

  def base?
    name == 'base'
  end

  def immersed_in?(other)
    immersible? && other.immersive? && !other.disabled? && target_audience == other.target_audience
  end

  def switch!
    Mumukit::Platform::Organization.switch! self
  end

  def to_s
    name
  end

  def url_for(path)
    Mumukit::Platform.laboratory.organic_url_for(name, path)
  end

  def url
    url_for '/'
  end

  def domain
    Mumukit::Platform.application.organic_domain(name)
  end

  ## API Exposure

  def to_param
    name
  end

  ## Resource Hash

  module ClassMethods
    def current
      Mumukit::Platform::Organization.current
    end

    def current?
      Mumukit::Platform::Organization.current?
    end

    def safe_current
      current if current?
    end

    def parse(json)
      json
        .slice(:name)
        .merge(theme: Mumuki::Domain::Organization::Theme.parse(json[:theme]))
        .merge(settings: Mumuki::Domain::Organization::Settings.parse(json[:settings]))
        .merge(profile: Mumuki::Domain::Organization::Profile.parse(json[:profile]))
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
mumuki-domain-9.23.0 lib/mumuki/domain/helpers/organization.rb
mumuki-domain-9.22.1 lib/mumuki/domain/helpers/organization.rb
mumuki-domain-9.22.0 lib/mumuki/domain/helpers/organization.rb
mumuki-domain-9.21.0 lib/mumuki/domain/helpers/organization.rb
mumuki-domain-9.20.0 lib/mumuki/domain/helpers/organization.rb
mumuki-domain-9.19.0 lib/mumuki/domain/helpers/organization.rb
mumuki-domain-9.18.0 lib/mumuki/domain/helpers/organization.rb
mumuki-domain-9.17.0 lib/mumuki/domain/helpers/organization.rb
mumuki-domain-9.16.0 lib/mumuki/domain/helpers/organization.rb
mumuki-domain-9.15.0 lib/mumuki/domain/helpers/organization.rb
mumuki-domain-9.14.1 lib/mumuki/domain/helpers/organization.rb
mumuki-domain-9.14.0 lib/mumuki/domain/helpers/organization.rb
mumuki-domain-9.13.1 lib/mumuki/domain/helpers/organization.rb
mumuki-domain-9.13.0 lib/mumuki/domain/helpers/organization.rb