Module: Ledge::UsesLedge::LocalInstanceMethods

Defined in:
lib/ledge/uses_ledge.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



21
22
23
24
25
26
27
28
# File 'lib/ledge/uses_ledge.rb', line 21

def method_missing method, *args, &block
  if method.to_s == "#{self.field}_ledge"
    content = JSON.parse read_attribute(self.class.field)
    return Ledge::Columns.new content
  else
    super
  end
end

Instance Method Details

#initialize(hash = {}) ⇒ Object



42
43
44
45
# File 'lib/ledge/uses_ledge.rb', line 42

def initialize hash = {}
  super
  ledge_init
end

#ledge_initObject



38
39
40
# File 'lib/ledge/uses_ledge.rb', line 38

def ledge_init
  self.content ||= '{"columns": [{"rows":[]}]}'
end

#respond_to?(method) ⇒ Boolean

Returns:

  • (Boolean)


30
31
32
33
34
35
36
# File 'lib/ledge/uses_ledge.rb', line 30

def respond_to? method
  if method.to_s == "#{self.field}_ledge"
    true
  else
    super
  end
end