Sha256: 52553602e0c2b1709b21e3913dd730a83bce6ae1d51491f485247d2504ac1134

Contents?: true

Size: 783 Bytes

Versions: 1

Compression:

Stored size: 783 Bytes

Contents

module Timber
  module Contexts
    module Organizations
      class ActionController < Organization
        DEFAULT_METHOD_NAME = :current_organization.freeze

        class << self
          attr_writer :method_name

          def method_name
            @method_name ||= DEFAULT_METHOD_NAME
          end
        end

        attr_reader :controller

        def initialize(controller)
          @controller = controller
          super()
        end

        private
          def method_name
            self.class.method_name
          end

          def organization
            return @organization if defined?(@organization)
            @organization = controller.respond_to?(method_name, true) ? controller.send(method_name) : nil
          end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
timberio-1.0.0.beta1 lib/timber/contexts/organizations/action_controller.rb