lib/virtus_model/base.rb
# Extract model attributes into a hash.
Extract model attributes into a hash.
Extract model attributes into a hash .
def extract_attributes(model)
      self.class.attributes.reduce({}) do |result, name|
        if model.respond_to?(name)
          result[name] = model.public_send(name)
        elsif model.respond_to?(:[]) && model.respond_to?(:key?) && model.key?(name)
          result[name] = model[name]
        end
        result
      end
    end
def extract_attributes ( model ) self . class . attributes . reduce ( { } ) do | result , name | if model . respond_to? ( name ) result [ name ] = model . public_send ( name ) elsif model . respond_to? ( :[] ) && model . respond_to? ( :key? ) && model . key? ( name ) result [ name ] = model [ name ] end result end end
Extract model attributes into a hash.
Extract model attributes into a hash .
model
<not_specific>