Module: IronNails::Wpf::Builders
- Included in:
- Panel
- Defined in:
- lib/ironnails/wpf.rb
Instance Method Summary collapse
- #[](name) ⇒ Object
- #add_class_to_name_collector(collection, klass, args = {}, &b) ⇒ Object
- #add_object_to_name_collector(collection, obj, args = {}, &b) ⇒ Object
- #assign_to_name_collector(property, klass, args = {}, &b) ⇒ Object
- #evaluate_properties(obj, args, &b) ⇒ Object
- #inject_names(obj) ⇒ Object
- #name_collector ⇒ Object
Instance Method Details
#[](name) ⇒ Object
9 10 11 |
# File 'lib/ironnails/wpf.rb', line 9 def [](name) name_collector[name] end |
#add_class_to_name_collector(collection, klass, args = {}, &b) ⇒ Object
50 51 52 53 54 55 |
# File 'lib/ironnails/wpf.rb', line 50 def add_class_to_name_collector(collection, klass, args = {}, &b) obj = evaluate_properties(klass.new, args, &b) obj.instance_eval(&b) unless b.nil? collection.add obj obj end |
#add_object_to_name_collector(collection, obj, args = {}, &b) ⇒ Object
43 44 45 46 47 48 |
# File 'lib/ironnails/wpf.rb', line 43 def add_object_to_name_collector(collection, obj, args = {}, &b) obj = evaluate_properties(obj, args, &b) obj.instance_eval(&b) unless b.nil? collection.add obj obj end |
#assign_to_name_collector(property, klass, args = {}, &b) ⇒ Object
57 58 59 60 61 62 |
# File 'lib/ironnails/wpf.rb', line 57 def assign_to_name_collector(property, klass, args = {}, &b) obj = evaluate_properties(klass.new, args, &b) obj.instance_eval(&b) unless b.nil? self.send property, obj obj end |
#evaluate_properties(obj, args, &b) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/ironnails/wpf.rb', line 17 def evaluate_properties(obj, args, &b) obj.instance_variable_set(:@___name_collector_, name_collector) args.each_pair do |k, v| if k == :name name_collector[v] = obj end if k == :binding binding = Binding.new binding.path = PropertyPath.new v[:property_name] binding.source = v[:target]||self; binding.mode = v[:mode] obj.set_binding(v[:property], binding); obj.owner = v[:target]||self else obj.send :"#{k.to_s}=", v end end if obj.respond_to? :name name_collector[obj.name] = obj unless obj.name.nil? end obj end |
#inject_names(obj) ⇒ Object
13 14 15 |
# File 'lib/ironnails/wpf.rb', line 13 def inject_names(obj) name_collector.each_pair { |k, v| obj.instance_variable_set("@#{k}".to_sym, v) } end |
#name_collector ⇒ Object
5 6 7 |
# File 'lib/ironnails/wpf.rb', line 5 def name_collector @___name_collector_ end |