Module: Countrizable::ActiveRecord::ActMacro

Defined in:
lib/countrizable/active_record/act_macro.rb

Instance Method Summary collapse

Instance Method Details

#class_nameObject



17
18
19
20
21
22
# File 'lib/countrizable/active_record/act_macro.rb', line 17

def class_name
  @class_name ||= begin
    class_name = table_name[table_name_prefix.length..-(table_name_suffix.length + 1)].downcase.camelize
    pluralize_table_names ? class_name.singularize : class_name
  end
end

#country_attribute(*attr_names) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/countrizable/active_record/act_macro.rb', line 4

def country_attribute(*attr_names)
  options = attr_names.extract_options!
  # Bypass setup_countries! if the initial bootstrapping is done already.
  setup_countries!(options) unless country_attribute?
  check_columns!(attr_names)

  # Add any extra country attributes.
  attr_names = attr_names.map(&:to_sym)
  attr_names -= country_attribute_names if defined?(country_attribute_names)

  allow_country_of_attributes(attr_names) if attr_names.present?
end

#country_attribute?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/countrizable/active_record/act_macro.rb', line 24

def country_attribute?
  included_modules.include?(InstanceMethods)
end