Sha256: ef7354ff2c66aa3579c3a5adcf6b0ea2e9d3ffd5c32887fba432ad4000373332

Contents?: true

Size: 704 Bytes

Versions: 5

Compression:

Stored size: 704 Bytes

Contents

class User < ActiveRecord::Base
  include Protoable

  def self.convert_base64_to_string(value)
    value
  end

  def self.convert_email_to_lowercase(value)
    value
  end

  def self.extract_first_name(proto)
    if proto.has_field?(:name)
      names = proto.name.split(" ")
      first_name = names.first
    end

    first_name
  end
  transform_column :first_name, :extract_first_name

  def self.extract_last_name(proto)
    if proto.has_field?(:name)
      names = proto.name.split(" ")
      names.shift # Drop the first name
      last_name = names.join(" ")
    end

    last_name
  end
  transform_column :last_name, :extract_last_name

  def name
    "#{first_name} #{last_name}"
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
protobuf-activerecord-1.0.5 spec/support/models/user.rb
protobuf-activerecord-1.0.4 spec/support/models/user.rb
protobuf-activerecord-1.0.3 spec/support/models/user.rb
protobuf-activerecord-1.0.2 spec/support/models/user.rb
protobuf-activerecord-1.0.1 spec/support/models/user.rb