Module: ActiveRecord::Serialization

Defined in:
lib/ruboss4ruby/active_foo.rb,
lib/ruboss4ruby/active_record_default_methods.rb

Overview

Flex-friendly serialization patches

Instance Method Summary collapse

Instance Method Details

#json_defaults_old_to_jsonObject



44
# File 'lib/ruboss4ruby/active_record_default_methods.rb', line 44

alias_method :json_defaults_old_to_json, :to_json

#to_fxml(options = {}, &block) ⇒ Object

Enforces Flex friendly options on XML and delegates processing to standard to_xml



133
134
135
136
137
138
# File 'lib/ruboss4ruby/active_foo.rb', line 133

def to_fxml(options = {}, &block)
  options.merge!(:dasherize => false)
  default_except = [:crypted_password, :salt, :remember_token, :remember_token_expires_at]
  options[:except] = (options[:except] ? options[:except] + default_except : default_except)
  to_xml(options, &block)
end

#to_json(options = {}, &block) ⇒ Object

adds support for default_methods to standard to_json



57
58
59
60
61
62
63
64
# File 'lib/ruboss4ruby/active_record_default_methods.rb', line 57

def to_json(options = {}, &block)
  unless options[:ignore_defaults]
    unless options[:ignore_default_methods]
      options[:methods] = [options[:methods] || []].flatten + (self.class.defaults_hash[:methods] || [])
    end
  end
  json_defaults_old_to_json(options, &block)      
end

#to_xml(options = {}, &block) ⇒ Object

adds support for default_methods to standard to_xml



47
48
49
50
51
52
53
54
# File 'lib/ruboss4ruby/active_record_default_methods.rb', line 47

def to_xml(options = {}, &block)
  unless options[:ignore_defaults]
    unless options[:ignore_default_methods]
      options[:methods] = [options[:methods] || []].flatten + (self.class.defaults_hash[:methods] || [])
    end
  end
  xml_defaults_old_to_xml(options, &block)
end

#xml_defaults_old_to_xmlObject



42
# File 'lib/ruboss4ruby/active_record_default_methods.rb', line 42

alias_method :xml_defaults_old_to_xml, :to_xml