Class: AwesomeTranslations::Handler

Inherits:
Object
  • Object
show all
Defined in:
app/models/awesome_translations/handler.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Handler

Returns a new instance of Handler.



16
17
18
# File 'app/models/awesome_translations/handler.rb', line 16

def initialize(data)
  @data = data
end

Class Method Details

.allObject



4
5
6
# File 'app/models/awesome_translations/handler.rb', line 4

def self.all
  AwesomeTranslations::Handlers.list
end

.find(id) ⇒ Object

Raises:

  • (ActiveRecord::RecordNotFound)


8
9
10
11
12
13
14
# File 'app/models/awesome_translations/handler.rb', line 8

def self.find(id)
  AwesomeTranslations::Handlers.list.each do |handler|
    return handler if handler.id == id.to_s
  end

  raise ActiveRecord::RecordNotFound, "Handlers not found: '#{id}'."
end

Instance Method Details

#constObject



32
33
34
# File 'app/models/awesome_translations/handler.rb', line 32

def const
  AwesomeTranslations::Handlers.const_get(@data.fetch(:const_name))
end

#groupsObject



40
41
42
# File 'app/models/awesome_translations/handler.rb', line 40

def groups
  const.new.groups
end

#idObject



20
21
22
# File 'app/models/awesome_translations/handler.rb', line 20

def id
  @data.fetch(:id)
end

#instanceObject



36
37
38
# File 'app/models/awesome_translations/handler.rb', line 36

def instance
  const.new
end

#nameObject



28
29
30
# File 'app/models/awesome_translations/handler.rb', line 28

def name
  @data.fetch(:name)
end

#to_paramObject



24
25
26
# File 'app/models/awesome_translations/handler.rb', line 24

def to_param
  id
end