Sha256: ca72357ccb3321eb22b691aa80ffdaf04be88019e99f51de5b40a08b25d9f54b
Contents?: true
Size: 1.01 KB
Versions: 5
Compression:
Stored size: 1.01 KB
Contents
class User < ActiveRecord::Base include Protobuf::ActiveRecord::Model attr_accessor :password has_many :photos accepts_nested_attributes_for :photos scope :by_guid, lambda { |*guids| where(:guid => guids) } scope :by_email, lambda { |*emails| where(:email => emails) } protobuf_fields :except => :photos attribute_from_proto :first_name, :extract_first_name attribute_from_proto :last_name, :extract_last_name attribute_from_proto :password, lambda { |proto| proto.password! } field_from_record :email_domain, lambda { |record| record.email.split('@').last } def self.extract_first_name(proto) if proto.field?(:name) names = proto.name.split(" ") first_name = names.first end first_name end def self.extract_last_name(proto) if proto.field?(:name) names = proto.name.split(" ") names.shift # Drop the first name last_name = names.join(" ") end last_name end def token "key" end def name "#{first_name} #{last_name}" end end
Version data entries
5 entries across 5 versions & 1 rubygems