Class: RailsI18nManager::Forms::Base

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Validations
Defined in:
app/lib/rails_i18n_manager/forms/base.rb

Direct Known Subclasses

TranslationFileForm

Instance Method Summary collapse

Constructor Details

#initialize(attrs = {}) ⇒ Base

Returns a new instance of Base.



6
7
8
9
10
11
12
# File 'app/lib/rails_i18n_manager/forms/base.rb', line 6

def initialize(attrs={})
  attrs ||= {}

  attrs.each do |k,v|
    self.send("#{k}=", v) ### Use send so that it checks that attr_accessor has already defined the method so its a valid attribute
  end
end

Instance Method Details

#model_nameObject



18
19
20
21
# File 'app/lib/rails_i18n_manager/forms/base.rb', line 18

def model_name
  sanitized_class_name = self.class.name.to_s.gsub("Forms::", '').gsub(/Form$/, '')
  ActiveModel::Name.new(self, self.class.superclass, sanitized_class_name)
end

#to_keyObject



14
15
16
# File 'app/lib/rails_i18n_manager/forms/base.rb', line 14

def to_key
  nil
end