Flowdock
method

serializable_hash

Importance_0
v3.1.0 - Show latest stable - 0 notes - Class: ActiveModel::Serialization
serializable_hash(options = nil) public

No documentation

This method has no description. You can help the Ruby on Rails community by adding new notes.

Hide source
# File activemodel/lib/active_model/serialization.rb, line 71
    def serializable_hash(options = nil)
      options ||= {}

      only   = Array.wrap(options[:only]).map(&:to_s)
      except = Array.wrap(options[:except]).map(&:to_s)

      attribute_names = attributes.keys.sort
      if only.any?
        attribute_names &= only
      elsif except.any?
        attribute_names -= except
      end

      method_names = Array.wrap(options[:methods]).map { |n| n if respond_to?(n.to_s) }.compact
      Hash[(attribute_names + method_names).map { |n| [n, send(n)] }]
    end
Register or log in to add new notes.