Module: PersonName::ActiveRecord::ClassMethods

Defined in:
lib/person_name.rb

Instance Method Summary collapse

Instance Method Details

#has_person_name(*name_types) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/person_name.rb', line 15

def has_person_name(*name_types)
	name_types = name_types.to_a.flatten.compact.map(&:to_sym)
	name_types << :name if name_types.empty?

	if has_person_names?
		write_inheritable_attribute(:name_types, (self.name_types + name_types).uniq)
	else
		write_inheritable_attribute(:name_types, name_types)
		class_inheritable_reader(:name_types)

		class_eval do
			def self.has_person_names?
				true
			end

			include PersonName::ActiveRecord::Core
		end
	end
end

#has_person_names?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/person_name.rb', line 11

def has_person_names?
 	false
end