Class: Worldwide::Field
- Inherits:
-
Object
- Object
- Worldwide::Field
- Defined in:
- lib/worldwide/field.rb
Constant Summary collapse
- VALID_KEYS =
[ :first_name, :last_name, :company, :address1, :address2, :city, :province, :zip, :country, :phone, ]
Instance Method Summary collapse
- #autofill(locale: I18n.locale) ⇒ Object
- #error(locale: I18n.locale, code:, options: {}) ⇒ Object
-
#initialize(country_code:, field_key:) ⇒ Field
constructor
A new instance of Field.
- #label(locale: I18n.locale) ⇒ Object
- #label_marked_optional(locale: I18n.locale) ⇒ Object
Constructor Details
#initialize(country_code:, field_key:) ⇒ Field
Returns a new instance of Field.
22 23 24 25 |
# File 'lib/worldwide/field.rb', line 22 def initialize(country_code:, field_key:) @country_code = country_code.upcase.to_sym @field_key = field_key.downcase.to_sym end |
Instance Method Details
#autofill(locale: I18n.locale) ⇒ Object
27 28 29 |
# File 'lib/worldwide/field.rb', line 27 def autofill(locale: I18n.locale) lookup("autofill", locale: locale) end |
#error(locale: I18n.locale, code:, options: {}) ⇒ Object
39 40 41 |
# File 'lib/worldwide/field.rb', line 39 def error(locale: I18n.locale, code:, options: {}) lookup("errors.#{code}", locale: locale, options: ) end |
#label(locale: I18n.locale) ⇒ Object
31 32 33 |
# File 'lib/worldwide/field.rb', line 31 def label(locale: I18n.locale) lookup("label.default", locale: locale) end |
#label_marked_optional(locale: I18n.locale) ⇒ Object
35 36 37 |
# File 'lib/worldwide/field.rb', line 35 def label_marked_optional(locale: I18n.locale) lookup("label.optional", locale: locale) end |