Class: Knockout::ViewModel
- Inherits:
-
Object
- Object
- Knockout::ViewModel
- Defined in:
- lib/opal/knockout/view_model.rb
Class Attribute Summary collapse
-
._computed_methods ⇒ Object
Returns the value of attribute _computed_methods.
-
._observable_arrays ⇒ Object
Returns the value of attribute _observable_arrays.
-
._observables ⇒ Object
Returns the value of attribute _observables.
Class Method Summary collapse
- .attr_computed(name, method_name = nil, &block) ⇒ Object
- .attr_observable(*names) ⇒ Object
- .attr_observable_array(*names) ⇒ Object
- .new(*args, &blk) ⇒ Object
Class Attribute Details
._computed_methods ⇒ Object
Returns the value of attribute _computed_methods.
6 7 8 |
# File 'lib/opal/knockout/view_model.rb', line 6 def _computed_methods @_computed_methods end |
._observable_arrays ⇒ Object
Returns the value of attribute _observable_arrays.
5 6 7 |
# File 'lib/opal/knockout/view_model.rb', line 5 def _observable_arrays @_observable_arrays end |
._observables ⇒ Object
Returns the value of attribute _observables.
4 5 6 |
# File 'lib/opal/knockout/view_model.rb', line 4 def _observables @_observables end |
Class Method Details
.attr_computed(name, method_name = nil, &block) ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/opal/knockout/view_model.rb', line 24 def attr_computed(name, method_name=nil, &block) raise ArgumentError, "#{self.to_s}##{__method__}: You must set method_name or block" if method_name.nil? && !block_given? return if method_name.nil? && !block_given? self._computed_methods ||= {} self._computed_methods[name] = if method_name.nil? block else method_name end end |
.attr_observable(*names) ⇒ Object
16 17 18 |
# File 'lib/opal/knockout/view_model.rb', line 16 def attr_observable(*names) names.each { |name| define_observable_accessor(name) } end |
.attr_observable_array(*names) ⇒ Object
20 21 22 |
# File 'lib/opal/knockout/view_model.rb', line 20 def attr_observable_array(*names) names.each { |name| define_observable_array_accessor(name) } end |
.new(*args, &blk) ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/opal/knockout/view_model.rb', line 8 def new( *args, &blk ) object = allocate object.before_initialize object.instance_eval{ initialize( *args, &blk ) } object.after_initialize object end |