Class: Object
- Inherits:
- BasicObject
- Defined in:
- lib/developwithpassion_expander/object_extensions.rb
Instance Method Summary collapse
- #array(name) {|dsl| ... } ⇒ Object
- #initialize_arrays(*items) ⇒ Object
- #initialize_defaults(factory, *items) ⇒ Object
- #initialize_false(*items) ⇒ Object
- #initialize_hashes(*items) ⇒ Object
Instance Method Details
#array(name) {|dsl| ... } ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/developwithpassion_expander/object_extensions.rb', line 20 def array(name,&block) initialize_arrays(name) dsl = DevelopWithPassion::Expander::ArrayDSL.new(name) yield dsl if block_given? modules = DevelopWithPassion::Expander::ArrayDSLModuleFactory.new.create_modules_from(dsl) modules.each{|new_module| self.extend(new_module)} end |
#initialize_arrays(*items) ⇒ Object
8 9 10 |
# File 'lib/developwithpassion_expander/object_extensions.rb', line 8 def initialize_arrays(*items) initialize_defaults(lambda{[]},*items) end |
#initialize_defaults(factory, *items) ⇒ Object
2 3 4 5 6 |
# File 'lib/developwithpassion_expander/object_extensions.rb', line 2 def initialize_defaults(factory,*items) items.each do|item| instance_variable_set("@#{item}",factory.call) end end |
#initialize_false(*items) ⇒ Object
16 17 18 |
# File 'lib/developwithpassion_expander/object_extensions.rb', line 16 def initialize_false(*items) initialize_defaults(lambda{false},*items) end |
#initialize_hashes(*items) ⇒ Object
12 13 14 |
# File 'lib/developwithpassion_expander/object_extensions.rb', line 12 def initialize_hashes(*items) initialize_defaults(lambda{{}},*items) end |