Class: RespondForHelper::Formats::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/respond_for_helper/formats/base.rb

Direct Known Subclasses

Html, Json

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(controller, item, success, options) ⇒ Base

Returns a new instance of Base.



11
12
13
14
15
16
17
18
19
# File 'lib/respond_for_helper/formats/base.rb', line 11

def initialize(controller, item, success, options)
  @controller = controller
  @item = item
  @result = success ? :success : :failure
  @options = options

  @format = self.class.format.to_sym
  @behaviour = Behaviours.new(@controller, @format, @result, @options).call
end

Instance Attribute Details

#behaviourObject (readonly)

Returns the value of attribute behaviour.



8
9
10
# File 'lib/respond_for_helper/formats/base.rb', line 8

def behaviour
  @behaviour
end

#controllerObject (readonly)

Returns the value of attribute controller.



8
9
10
# File 'lib/respond_for_helper/formats/base.rb', line 8

def controller
  @controller
end

#formatObject (readonly)

Returns the value of attribute format.



8
9
10
# File 'lib/respond_for_helper/formats/base.rb', line 8

def format
  @format
end

#itemObject (readonly)

Returns the value of attribute item.



8
9
10
# File 'lib/respond_for_helper/formats/base.rb', line 8

def item
  @item
end

#resultObject (readonly)

Returns the value of attribute result.



8
9
10
# File 'lib/respond_for_helper/formats/base.rb', line 8

def result
  @result
end

Instance Method Details

#callObject



21
22
23
24
25
26
27
# File 'lib/respond_for_helper/formats/base.rb', line 21

def call
  if respond_to?("_#{action_name}", true)
    send("_#{action_name}")
  else
    perform
  end
end