cascading-configuration-array 1.4.0 → 1.4.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -16,6 +16,8 @@ module CascadingConfiguration
16
16
  module AccessorDefinitionMethods
17
17
  end
18
18
  module Interface
19
+ module Instance
20
+ end
19
21
  end
20
22
  module ObjectInstance
21
23
  end
@@ -30,3 +32,4 @@ require_relative 'cascading-configuration-array/CascadingConfiguration/_private_
30
32
  require_relative 'cascading-configuration-array/CascadingConfiguration/Array.rb'
31
33
  require_relative 'cascading-configuration-array/CascadingConfiguration/Array/AccessorDefinitionMethods.rb'
32
34
  require_relative 'cascading-configuration-array/CascadingConfiguration/Array/Interface.rb'
35
+ require_relative 'cascading-configuration-array/CascadingConfiguration/Array/Interface/Instance.rb'
@@ -14,6 +14,8 @@ module CascadingConfiguration::Array
14
14
  class_or_module.extend_also_extends( CascadingConfiguration::Variable::EigenclassConfigurationChain )
15
15
  end
16
16
 
17
+ include_cascades_extends( CascadingConfiguration::Array::Interface::Instance )
18
+
17
19
  include_cascades_extends( CascadingConfiguration::Array )
18
20
 
19
21
  prepend_module_include do |class_or_module|
@@ -114,7 +114,7 @@ module CascadingConfiguration::Array::AccessorDefinitionMethods
114
114
 
115
115
  def define_instance_configuration_array_setter( configuration_name )
116
116
  configuration_setter_name = ( configuration_name.to_s + '=' ).to_sym
117
- accessor_local_instance_support.module_eval do
117
+ accessor_instance_support.module_eval do
118
118
  define_method( configuration_setter_name ) do |array|
119
119
  composite_array = composite_array_for_cascading_configuration( configuration_name )
120
120
  # we want the array to supplant existing config
@@ -132,6 +132,38 @@ module CascadingConfiguration::Array::AccessorDefinitionMethods
132
132
  ################################################
133
133
 
134
134
  def define_instance_configuration_array_getter( configuration_name )
135
+ configuration_getter_name = configuration_name
136
+ accessor_instance_support.module_eval do
137
+ define_method( configuration_getter_name ) do
138
+ return composite_array_for_cascading_configuration( configuration_name )
139
+ end
140
+ end
141
+ end
142
+
143
+ ##############################################
144
+ # define_object_configuration_array_setter #
145
+ ##############################################
146
+
147
+ def define_object_configuration_array_setter( configuration_name )
148
+ configuration_setter_name = ( configuration_name.to_s + '=' ).to_sym
149
+ accessor_local_instance_support.module_eval do
150
+ define_method( configuration_setter_name ) do |array|
151
+ composite_array = composite_array_for_cascading_configuration( configuration_name )
152
+ # we want the array to supplant existing config
153
+ # clear the array (excludes everything explicitly)
154
+ composite_array.clear
155
+ # push array elements (removes anything excluded from exclude)
156
+ composite_array.push( *array )
157
+ return composite_array
158
+ end
159
+ end
160
+ end
161
+
162
+ ##############################################
163
+ # define_object_configuration_array_getter #
164
+ ##############################################
165
+
166
+ def define_object_configuration_array_getter( configuration_name )
135
167
  configuration_getter_name = configuration_name
136
168
  accessor_local_instance_support.module_eval do
137
169
  define_method( configuration_getter_name ) do
@@ -51,19 +51,19 @@ module CascadingConfiguration::Array::Interface
51
51
  CascadingConfiguration::Variable.cascade_local_instance( self )
52
52
  end
53
53
 
54
- #######################################
55
- # attr_instance_configuration_array #
56
- #######################################
54
+ #####################################
55
+ # attr_object_configuration_array #
56
+ #####################################
57
57
 
58
- # defines configuration in present class or module context
58
+ # defines configuration in present instance
59
59
  # configuration does not cascade
60
- def attr_instance_configuration_array( *property_names )
60
+ def attr_object_configuration_array( *property_names )
61
61
  CascadingConfiguration::Variable.define_accessor_local_instance_support( self )
62
62
  property_names.each do |this_property_name|
63
63
  # define configuration setter
64
- define_instance_configuration_array_setter( this_property_name )
64
+ define_object_configuration_array_setter( this_property_name )
65
65
  # define configuration getter
66
- define_instance_configuration_array_getter( this_property_name )
66
+ define_object_configuration_array_getter( this_property_name )
67
67
  end
68
68
  end
69
69
 
@@ -0,0 +1,22 @@
1
+
2
+ module CascadingConfiguration::Array::Interface::Instance
3
+
4
+ extend CascadingConfiguration::InternalModuleStub
5
+
6
+ #######################################
7
+ # attr_instance_configuration_array #
8
+ #######################################
9
+
10
+ # defines configuration in present class or module context
11
+ # configuration does not cascade
12
+ def attr_instance_configuration_array( *property_names )
13
+ property_names.each do |this_property_name|
14
+ # define configuration setter
15
+ define_instance_configuration_array_setter( this_property_name )
16
+ # define configuration getter
17
+ define_instance_configuration_array_getter( this_property_name )
18
+ end
19
+ return self
20
+ end
21
+
22
+ end
@@ -484,7 +484,7 @@ describe CascadingConfiguration::Array do
484
484
  # attr_instance_configuration_array #
485
485
  #######################################
486
486
 
487
- it 'can define a local configuration array, which will not cascade' do
487
+ it 'can define an instance configuration array, which will not cascade' do
488
488
 
489
489
  # possibilities:
490
490
  # * module extended with setting
@@ -501,13 +501,7 @@ describe CascadingConfiguration::Array do
501
501
  module CascadingConfiguration::Array::InstanceConfigurationMockModuleExtended
502
502
  extend CascadingConfiguration::Array
503
503
  # => singleton gets attr_configuration and configurations
504
- respond_to?( :attr_instance_configuration_array ).should == true
505
- attr_instance_configuration_array :configuration_setting
506
- respond_to?( :configuration_setting ).should == true
507
- configuration_setting.should == []
508
- configuration_setting.push( :a_configuration )
509
- configuration_setting.should == [ :a_configuration ]
510
- instance_methods.include?( :configuration_setting ).should == false
504
+ respond_to?( :attr_instance_configuration_array ).should == false
511
505
  instance_variables.empty?.should == true
512
506
  # => including modules and classes get nothing
513
507
  module SubmoduleIncluding
@@ -544,6 +538,139 @@ describe CascadingConfiguration::Array do
544
538
  # => singleton gets attr_configuration and configurations
545
539
  respond_to?( :attr_instance_configuration_array ).should == true
546
540
  attr_instance_configuration_array :configuration_setting
541
+ respond_to?( :configuration_setting ).should == false
542
+ instance_methods.include?( :configuration_setting ).should == true
543
+ instance_variables.empty?.should == true
544
+ # => including modules and classes get attr_configuration and configurations
545
+ module SubmoduleIncluding
546
+ include CascadingConfiguration::Array::InstanceConfigurationMockModuleIncluded
547
+ instance_methods.include?( :configuration_setting ).should == true
548
+ respond_to?( :configuration_setting ).should == false
549
+ instance_methods.include?( :configuration_setting ).should == true
550
+ instance_variables.empty?.should == true
551
+ end
552
+ # => extending modules and classes get attr_configuration and configurations
553
+ module SubmoduleExtending
554
+ extend CascadingConfiguration::Array::InstanceConfigurationMockModuleIncluded
555
+ # if we're extended then we want to use the eigenclass ancestor chain
556
+ # - the first ancestor will be the extending module
557
+ # - the rest of the ancestors will be the extending module's include chain
558
+ respond_to?( :configuration_setting ).should == true
559
+ instance_methods.include?( :configuration_setting ).should == false
560
+ instance_variables.empty?.should == true
561
+ end
562
+ # => instances of including classes get configurations
563
+ class ClassIncluding
564
+ include CascadingConfiguration::Array::InstanceConfigurationMockModuleIncluded
565
+ instance_methods.include?( :configuration_setting ).should == true
566
+ respond_to?( :configuration_setting ).should == false
567
+ instance_variables.empty?.should == true
568
+ end
569
+ setting_class_including_instance = ClassIncluding.new
570
+ setting_class_including_instance.respond_to?( :configuration_setting ).should == true
571
+ setting_class_including_instance.instance_variables.empty?.should == true
572
+ # => instances of extending classes get nothing
573
+ class ClassExtending
574
+ extend CascadingConfiguration::Array::InstanceConfigurationMockModuleIncluded
575
+ instance_methods.include?( :configuration_setting ).should == false
576
+ respond_to?( :configuration_setting ).should == true
577
+ instance_variables.empty?.should == true
578
+ end
579
+ setting_class_including_instance = ClassExtending.new
580
+ setting_class_including_instance.respond_to?( :configuration_setting ).should == false
581
+ setting_class_including_instance.instance_variables.empty?.should == true
582
+ end
583
+
584
+ class CascadingConfiguration::Array::InstanceConfigurationMockClass
585
+ include CascadingConfiguration::Array::InstanceConfigurationMockModuleIncluded::SubmoduleIncluding
586
+ instance_methods.include?( :configuration_setting ).should == true
587
+ respond_to?( :configuration_setting ).should == false
588
+ instance_variables.empty?.should == true
589
+ end
590
+ object_instance_one = CascadingConfiguration::Array::InstanceConfigurationMockClass.new
591
+ object_instance_one.respond_to?( :configuration_setting ).should == true
592
+ object_instance_one.instance_variables.empty?.should == true
593
+ class CascadingConfiguration::Array::InstanceConfigurationMockClassSub1 < CascadingConfiguration::Array::InstanceConfigurationMockClass
594
+ instance_methods.include?( :configuration_setting ).should == true
595
+ respond_to?( :configuration_setting ).should == false
596
+ instance_variables.empty?.should == true
597
+ end
598
+ object_instance_two = CascadingConfiguration::Array::InstanceConfigurationMockClassSub1.new
599
+ object_instance_two.respond_to?( :configuration_setting ).should == true
600
+ object_instance_two.instance_variables.empty?.should == true
601
+ class CascadingConfiguration::Array::InstanceConfigurationMockClassSub2 < CascadingConfiguration::Array::InstanceConfigurationMockClassSub1
602
+ instance_methods.include?( :configuration_setting ).should == true
603
+ respond_to?( :configuration_setting ).should == false
604
+ instance_variables.empty?.should == true
605
+ end
606
+
607
+ end
608
+
609
+
610
+ #####################################
611
+ # attr_object_configuration_array #
612
+ #####################################
613
+
614
+ it 'can define an object configuration array, which will not cascade' do
615
+
616
+ # possibilities:
617
+ # * module extended with setting
618
+ # => singleton gets attr_configuration and configurations
619
+ # => including modules and classes get nothing
620
+ # => extending modules and classes get nothing
621
+ # => instances of including and extending classes get nothing
622
+ # * module included with setting
623
+ # => singleton gets attr_configuration and configurations
624
+ # => including modules and classes get attr_configuration and configurations
625
+ # => instances of including classes get configurations
626
+ # => extending modules and classes get attr_configuration and configurations
627
+ # => instances of extending classes get nothing
628
+ module CascadingConfiguration::Array::ObjectConfigurationMockModuleExtended
629
+ extend CascadingConfiguration::Array
630
+ # => singleton gets attr_configuration and configurations
631
+ respond_to?( :attr_object_configuration_array ).should == true
632
+ attr_object_configuration_array :configuration_setting
633
+ respond_to?( :configuration_setting ).should == true
634
+ configuration_setting.should == []
635
+ configuration_setting.push( :a_configuration )
636
+ configuration_setting.should == [ :a_configuration ]
637
+ instance_methods.include?( :configuration_setting ).should == false
638
+ instance_variables.empty?.should == true
639
+ # => including modules and classes get nothing
640
+ module SubmoduleIncluding
641
+ include CascadingConfiguration::Array::ObjectConfigurationMockModuleExtended
642
+ instance_methods.include?( :configuration_setting ).should == false
643
+ respond_to?( :configuration_setting ).should == false
644
+ instance_variables.empty?.should == true
645
+ end
646
+ # => extending modules and classes get nothing
647
+ module SubmoduleExtending
648
+ extend CascadingConfiguration::Array::ObjectConfigurationMockModuleExtended
649
+ instance_methods.include?( :configuration_setting ).should == false
650
+ respond_to?( :configuration_setting ).should == false
651
+ instance_variables.empty?.should == true
652
+ end
653
+ # => instances of including and extending classes get nothing
654
+ class ClassIncluding
655
+ include CascadingConfiguration::Array::ObjectConfigurationMockModuleExtended
656
+ instance_methods.include?( :configuration_setting ).should == false
657
+ respond_to?( :configuration_setting ).should == false
658
+ instance_variables.empty?.should == true
659
+ end
660
+ class ClassExtending
661
+ extend CascadingConfiguration::Array::ObjectConfigurationMockModuleExtended
662
+ instance_methods.include?( :configuration_setting ).should == false
663
+ respond_to?( :configuration_setting ).should == false
664
+ instance_variables.empty?.should == true
665
+ end
666
+ end
667
+
668
+ # * module included with setting
669
+ module CascadingConfiguration::Array::ObjectConfigurationMockModuleIncluded
670
+ include CascadingConfiguration::Array
671
+ # => singleton gets attr_configuration and configurations
672
+ respond_to?( :attr_object_configuration_array ).should == true
673
+ attr_object_configuration_array :configuration_setting
547
674
  respond_to?( :configuration_setting ).should == true
548
675
  configuration_setting.should == []
549
676
  configuration_setting.push( :a_configuration )
@@ -552,7 +679,7 @@ describe CascadingConfiguration::Array do
552
679
  instance_variables.empty?.should == true
553
680
  # => including modules and classes get attr_configuration and configurations
554
681
  module SubmoduleIncluding
555
- include CascadingConfiguration::Array::InstanceConfigurationMockModuleIncluded
682
+ include CascadingConfiguration::Array::ObjectConfigurationMockModuleIncluded
556
683
  instance_methods.include?( :configuration_setting ).should == false
557
684
  respond_to?( :configuration_setting ).should == false
558
685
  instance_methods.include?( :configuration_setting ).should == false
@@ -560,7 +687,7 @@ describe CascadingConfiguration::Array do
560
687
  end
561
688
  # => extending modules and classes get attr_configuration and configurations
562
689
  module SubmoduleExtending
563
- extend CascadingConfiguration::Array::InstanceConfigurationMockModuleIncluded
690
+ extend CascadingConfiguration::Array::ObjectConfigurationMockModuleIncluded
564
691
  # if we're extended then we want to use the eigenclass ancestor chain
565
692
  # - the first ancestor will be the extending module
566
693
  # - the rest of the ancestors will be the extending module's include chain
@@ -570,7 +697,7 @@ describe CascadingConfiguration::Array do
570
697
  end
571
698
  # => instances of including classes get configurations
572
699
  class ClassIncluding
573
- include CascadingConfiguration::Array::InstanceConfigurationMockModuleIncluded
700
+ include CascadingConfiguration::Array::ObjectConfigurationMockModuleIncluded
574
701
  instance_methods.include?( :configuration_setting ).should == false
575
702
  respond_to?( :configuration_setting ).should == false
576
703
  instance_variables.empty?.should == true
@@ -580,7 +707,7 @@ describe CascadingConfiguration::Array do
580
707
  setting_class_including_instance.instance_variables.empty?.should == true
581
708
  # => instances of extending classes get nothing
582
709
  class ClassExtending
583
- extend CascadingConfiguration::Array::InstanceConfigurationMockModuleIncluded
710
+ extend CascadingConfiguration::Array::ObjectConfigurationMockModuleIncluded
584
711
  instance_methods.include?( :configuration_setting ).should == false
585
712
  respond_to?( :configuration_setting ).should == false
586
713
  instance_variables.empty?.should == true
@@ -590,24 +717,24 @@ describe CascadingConfiguration::Array do
590
717
  setting_class_including_instance.instance_variables.empty?.should == true
591
718
  end
592
719
 
593
- class CascadingConfiguration::Array::InstanceConfigurationMockClass
594
- include CascadingConfiguration::Array::InstanceConfigurationMockModuleIncluded::SubmoduleIncluding
720
+ class CascadingConfiguration::Array::ObjectConfigurationMockClass
721
+ include CascadingConfiguration::Array::ObjectConfigurationMockModuleIncluded::SubmoduleIncluding
595
722
  instance_methods.include?( :configuration_setting ).should == false
596
723
  respond_to?( :configuration_setting ).should == false
597
724
  instance_variables.empty?.should == true
598
725
  end
599
- object_instance_one = CascadingConfiguration::Array::InstanceConfigurationMockClass.new
726
+ object_instance_one = CascadingConfiguration::Array::ObjectConfigurationMockClass.new
600
727
  object_instance_one.respond_to?( :configuration_setting ).should == false
601
728
  object_instance_one.instance_variables.empty?.should == true
602
- class CascadingConfiguration::Array::InstanceConfigurationMockClassSub1 < CascadingConfiguration::Array::InstanceConfigurationMockClass
729
+ class CascadingConfiguration::Array::ObjectConfigurationMockClassSub1 < CascadingConfiguration::Array::ObjectConfigurationMockClass
603
730
  instance_methods.include?( :configuration_setting ).should == false
604
731
  respond_to?( :configuration_setting ).should == false
605
732
  instance_variables.empty?.should == true
606
733
  end
607
- object_instance_two = CascadingConfiguration::Array::InstanceConfigurationMockClassSub1.new
734
+ object_instance_two = CascadingConfiguration::Array::ObjectConfigurationMockClassSub1.new
608
735
  object_instance_two.respond_to?( :configuration_setting ).should == false
609
736
  object_instance_two.instance_variables.empty?.should == true
610
- class CascadingConfiguration::Array::InstanceConfigurationMockClassSub2 < CascadingConfiguration::Array::InstanceConfigurationMockClassSub1
737
+ class CascadingConfiguration::Array::ObjectConfigurationMockClassSub2 < CascadingConfiguration::Array::ObjectConfigurationMockClassSub1
611
738
  instance_methods.include?( :configuration_setting ).should == false
612
739
  respond_to?( :configuration_setting ).should == false
613
740
  instance_variables.empty?.should == true
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 4
8
- - 0
9
- version: 1.4.0
8
+ - 1
9
+ version: 1.4.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Asher
@@ -55,6 +55,7 @@ files:
55
55
  - lib/cascading-configuration-array/CascadingConfiguration/_private_/CompositingArray.rb
56
56
  - lib/cascading-configuration-array/CascadingConfiguration/_private_/LocalConfigurationArray.rb
57
57
  - lib/cascading-configuration-array/CascadingConfiguration/Array/AccessorDefinitionMethods.rb
58
+ - lib/cascading-configuration-array/CascadingConfiguration/Array/Interface/Instance.rb
58
59
  - lib/cascading-configuration-array/CascadingConfiguration/Array/Interface.rb
59
60
  - lib/cascading-configuration-array/CascadingConfiguration/Array.rb
60
61
  - lib/cascading-configuration-array/CascadingConfiguration/CompositingArray/Instance.rb