Class: ActiveResponse::Responders::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/active_response/responders/base.rb

Direct Known Subclasses

HTML

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(controller, format) ⇒ Base

Returns a new instance of Base.



12
13
14
15
# File 'lib/active_response/responders/base.rb', line 12

def initialize(controller, format)
  self.controller = controller
  self.format = format
end

Instance Attribute Details

#controllerObject

Returns the value of attribute controller.



6
7
8
# File 'lib/active_response/responders/base.rb', line 6

def controller
  @controller
end

#formatObject

Returns the value of attribute format.



7
8
9
# File 'lib/active_response/responders/base.rb', line 7

def format
  @format
end

Class Method Details

.available_formatsObject



36
37
38
39
40
# File 'lib/active_response/responders/base.rb', line 36

def available_formats
  return @available_formats if @available_formats.present?
  @available_formats =
    ActiveResponse.registered_responders.map(&:formats).flatten.sort { |format| format == :html ? 0 : 1 }
end

.respond_to(*formats) ⇒ Object



28
29
30
# File 'lib/active_response/responders/base.rb', line 28

def respond_to(*formats)
  self.formats = formats
end

.typeObject



32
33
34
# File 'lib/active_response/responders/base.rb', line 32

def type
  @type ||= name.gsub('Responder', '').underscore.to_sym
end

Instance Method Details

#typeObject



17
18
19
# File 'lib/active_response/responders/base.rb', line 17

def type
  self.class.type
end