Class: Knockout::Computed

Inherits:
Object
  • Object
show all
Defined in:
lib/opal/knockout/computed.rb

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ Computed

Returns a new instance of Computed.



3
4
5
6
7
8
9
# File 'lib/opal/knockout/computed.rb', line 3

def initialize(&block)
  @callback = %x{
    ko.computed(function() {
      return #{block.call};
    });
  }
end

Instance Method Details

#to_nObject



15
16
17
# File 'lib/opal/knockout/computed.rb', line 15

def to_n
  @callback
end

#to_sObject



11
12
13
# File 'lib/opal/knockout/computed.rb', line 11

def to_s
  @callback.call
end