Class: Interpreter::Base

Inherits:
Object
  • Object
show all
Extended by:
ActiveModel::Naming, ActiveModel::Translation
Includes:
ActiveModel::AttributeMethods, ActiveModel::Conversion, ActiveModel::Validations
Defined in:
lib/interpreter/base.rb

Direct Known Subclasses

Translation

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.attributes(*names) ⇒ Object



13
14
15
16
17
# File 'lib/interpreter/base.rb', line 13

def self.attributes(*names)
  attr_accessor *names
  define_attribute_methods names
  self._attributes += names
end

.locales(*names) ⇒ Object



19
20
21
22
23
# File 'lib/interpreter/base.rb', line 19

def self.locales(*names)
  attr_accessor *names
  define_attribute_methods names
  self._attributes += names
end

Instance Method Details

#attributesObject



25
26
27
28
29
30
# File 'lib/interpreter/base.rb', line 25

def attributes
  self._attributes.inject({}) do |hash, attr|
    hash[attr.to_s] = send(attr)
    hash
  end
end

#new_record?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/interpreter/base.rb', line 36

def new_record?
  !persisted?
end

#persisted?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/interpreter/base.rb', line 32

def persisted?
  false
end