Module: Intermodal::Models::Presentation

Extended by:
ActiveSupport::Concern
Defined in:
lib/intermodal/concerns/models/presentation.rb

Instance Method Summary collapse

Instance Method Details

#as_json(opts = {}) ⇒ Object



6
7
8
9
# File 'lib/intermodal/concerns/models/presentation.rb', line 6

def as_json(opts = {})
  return presentation(opts) if opts && (opts[:presenter] || opts[:api])
  super(opts)
end

#presentation(opts) ⇒ Object



20
21
22
# File 'lib/intermodal/concerns/models/presentation.rb', line 20

def presentation(opts)
  presenter(opts).call(self, opts)
end

#presenter(opts) ⇒ Object



16
17
18
# File 'lib/intermodal/concerns/models/presentation.rb', line 16

def presenter(opts)
  opts[:presenter] || opts[:api].presenter_for(self.class)
end

#to_xml(opts = {}) ⇒ Object



11
12
13
14
# File 'lib/intermodal/concerns/models/presentation.rb', line 11

def to_xml(opts = {})
  return presentation(opts.except(:root)).to_xml(opts) if opts && (opts[:presenter] || opts[:api])
  super(opts)
end