class Seiun::Callback::RecordWrapper

Public Class Methods

new(record) click to toggle source
# File lib/seiun/callback/record_wrapper.rb, line 4
def initialize(record)
  @record = record
end

Public Instance Methods

to_hash() click to toggle source
# File lib/seiun/callback/record_wrapper.rb, line 8
def to_hash
  if callback_defined?(:hashalize)
    @record.__send__(:hashalize)
  elsif @record.respond_to?(:to_hash)
    @record.to_hash
  else
    @record
  end
end

Private Instance Methods

callback_defined?(name) click to toggle source
# File lib/seiun/callback/record_wrapper.rb, line 20
def callback_defined?(name)
  !!callbacks[name]
end
callbacks() click to toggle source
# File lib/seiun/callback/record_wrapper.rb, line 24
def callbacks
  return {} unless @record.class.respond_to?(:seiun_callbacks)
  return {} unless @record.class.seiun_callbacks.is_a?(Hash)
  @record.class.seiun_callbacks
end