Sha256: 8b99b00fd68443ac4faf0c0095ad0e7f2daf75e7b3cc604deac7e194c00edecf
Contents?: true
Size: 1.38 KB
Versions: 2
Compression:
Stored size: 1.38 KB
Contents
module IronNails module View # The base class for view models in an IronNails application. module ViewModelMixin include IronNails::Logging::ClassLogger def __view_model_name_ self.class.demodulize.underscore end # adds a model for the view in the dictionary def add_model(k, v) unless self.respond_to?(k) && self.respond_to?(:"#{k}=") logger.debug "adding object to the view model #{k}", IRONNAILS_FRAMEWORKNAME self.class.send :attr_accessor, k end self.send :"#{k}=", v end alias_method :set_model, :add_model # configures a command appropriately on the view. # for an EventCommand it will pass it to the view and the view will attach the # appropriate events # for a TimedCommand it will create a timer in the view proxy object # for a BehaviorCommand it will add the appropriate delegate command to the # Commands dictionary on the ViewModel class def add_command(cmd) dc = cmd.to_clr_command cmd_name = cmd.name.to_s unless self.respond_to?(cmd_name.to_sym) && self.respond_to?(:"#{cmd_name}=") logger.debug "adding command to the view model #{cmd_name}", IRONNAILS_FRAMEWORKNAME self.class.send :attr_accessor, cmd_name.to_sym end self.send :"#{cmd_name}=", dc end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ironnails-0.0.3 | lib/ironnails/view/view_model.rb |
ironnails-0.0.1 | lib/ironnails/view/view_model.rb |