Sha256: dc7e1fa3777b1f31cd5059d1315b11d383abc2e4867322ebc84c4f45d7c9a024
Contents?: true
Size: 933 Bytes
Versions: 14
Compression:
Stored size: 933 Bytes
Contents
# -*- coding: utf-8 -*- require 'reflex/model' module Reflex module ModelOwner attr_reader :model def model=(model) return if model == @model @model.remove_handler self if @model @model = model @model.add_handler self if @model model end def data=(data) unless data.nil? self.model = Model.new unless @model @model.data = data else self.model = nil end data end def data() @model ? @model.data : nil end def invoke(*args) @model.invoke(*args) if @model end def on_data_attach(e) invoke :update, {}, only: self end def on_data_detach(e) invoke :update, {}, only: self end [:int, :float, :string, :[], :[]=].each do |name| define_method name do |*args| @model ? @model.send(name, *args) : nil end end end# ModelOwner end# Reflex
Version data entries
14 entries across 14 versions & 1 rubygems