Class: Wakari::Proxy::Base

Inherits:
Object
  • Object
show all
Extended by:
ActiveModel::Naming
Includes:
ActiveModel::MassAssignmentSecurity
Defined in:
lib/wakari/models/proxy.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(content) ⇒ Base

Returns a new instance of Base.



14
15
16
# File 'lib/wakari/models/proxy.rb', line 14

def initialize(content)
  @content = content
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(*args, &block) ⇒ Object



32
33
34
# File 'lib/wakari/models/proxy.rb', line 32

def method_missing(*args, &block)
  current_translation.send(*args, &block)
end

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content.



8
9
10
# File 'lib/wakari/models/proxy.rb', line 8

def content
  @content
end

Instance Method Details

#dom_id(prefix = nil) ⇒ Object



36
37
38
# File 'lib/wakari/models/proxy.rb', line 36

def dom_id(prefix = nil)
  [prefix, content.dom_id, translations.klass.dom_class].compact.join("_")
end

#inspectObject



28
29
30
# File 'lib/wakari/models/proxy.rb', line 28

def inspect
  translations.inspect
end

#write(params = {}) ⇒ Object

def translations

_translations_proc.call(content)

end



22
23
24
25
26
# File 'lib/wakari/models/proxy.rb', line 22

def write(params={})
  detect_current_translation.tap do |t|
    t.attributes = params.delete_if {|k| k.to_s == "locale"}
  end
end