Sha256: 0a00cc7e2a3e91a2f3ed7257e7e9824d8d8fc8096ff4723869f198aad9e22445

Contents?: true

Size: 911 Bytes

Versions: 3

Compression:

Stored size: 911 Bytes

Contents

require 'alfa/wrapper'

module Alfa
  class Controller
    include Alfa::WrapperMethods

    attr_accessor :application, :request, :config, :app_sym, :c_sym, :params, :resourcer, :route

    def initialize(route: nil)
      @route = route
    end

    def self.__options
      @__options ||= {}
    end

    def render(type)
      self.class.options(caller_locations(1, 1)[0].label.to_sym, {render: type})
    end

    def self.options(method, opts)
      __options[method.to_sym] = __options[method.to_sym] ? __options[method.to_sym].merge(opts) : opts
    end

    def set_options(opts = {})
      self.class.options(caller_locations(1, 1)[0].label.to_sym, opts)
    end

    def self.get_content_type(method)
      o = __options[method]
      o.is_a?(Hash) ? o[:content_type] : nil
    end

    def self.get_render(method)
      o = __options[method]
      o.is_a?(Hash) ? o[:render] : nil
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
alfa-0.0.8.pre lib/alfa/controller.rb
alfa-0.0.7.pre lib/alfa/controller.rb
alfa-0.0.6.pre lib/alfa/controller.rb