Class: DataMiner::AttributeCollection
- Inherits:
-
Object
- Object
- DataMiner::AttributeCollection
- Defined in:
- lib/data_miner/attribute_collection.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
Returns the value of attribute attributes.
-
#klass ⇒ Object
Returns the value of attribute klass.
Instance Method Summary collapse
- #affect!(step, attr_name, attr_options = {}) ⇒ Object
- #affect_all_content_columns!(step, options = {}) ⇒ Object
- #all_affected_by(step) ⇒ Object
- #all_for(step) ⇒ Object
- #all_keys_for(step) ⇒ Object
- #has_conditional_writes_for?(step) ⇒ Boolean
- #has_keys_for?(step) ⇒ Boolean
-
#initialize(klass) ⇒ AttributeCollection
constructor
A new instance of AttributeCollection.
- #key!(step, attr_name, attr_options = {}) ⇒ Object
Constructor Details
#initialize(klass) ⇒ AttributeCollection
Returns a new instance of AttributeCollection.
5 6 7 8 |
# File 'lib/data_miner/attribute_collection.rb', line 5 def initialize(klass) @klass = klass @attributes = {} end |
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
3 4 5 |
# File 'lib/data_miner/attribute_collection.rb', line 3 def attributes @attributes end |
#klass ⇒ Object
Returns the value of attribute klass.
3 4 5 |
# File 'lib/data_miner/attribute_collection.rb', line 3 def klass @klass end |
Instance Method Details
#affect!(step, attr_name, attr_options = {}) ⇒ Object
14 15 16 |
# File 'lib/data_miner/attribute_collection.rb', line 14 def affect!(step, attr_name, = {}) find_or_initialize(attr_name).affected_by!(step, ) end |
#affect_all_content_columns!(step, options = {}) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/data_miner/attribute_collection.rb', line 18 def affect_all_content_columns!(step, = {}) except = Array.wrap([:except]).map(&:to_sym) step.klass.content_columns.map(&:name).reject { |content_column| except.include?(content_column.to_sym) }.each do |content_column| find_or_initialize(content_column).affected_by!(step) end end |
#all_affected_by(step) ⇒ Object
25 26 27 |
# File 'lib/data_miner/attribute_collection.rb', line 25 def all_affected_by(step) attributes.values.select { |attr| attr.affected_by?(step) } end |
#all_for(step) ⇒ Object
33 34 35 |
# File 'lib/data_miner/attribute_collection.rb', line 33 def all_for(step) (all_affected_by(step) + all_keys_for(step)).uniq end |
#all_keys_for(step) ⇒ Object
29 30 31 |
# File 'lib/data_miner/attribute_collection.rb', line 29 def all_keys_for(step) attributes.values.select { |attr| attr.key_for?(step) } end |
#has_conditional_writes_for?(step) ⇒ Boolean
41 42 43 |
# File 'lib/data_miner/attribute_collection.rb', line 41 def has_conditional_writes_for?(step) all_affected_by(step).any? { |attr| !attr.wants_overwriting?(step) } end |
#has_keys_for?(step) ⇒ Boolean
37 38 39 |
# File 'lib/data_miner/attribute_collection.rb', line 37 def has_keys_for?(step) attributes.values.any? { |attr| attr.key_for?(step) } end |
#key!(step, attr_name, attr_options = {}) ⇒ Object
10 11 12 |
# File 'lib/data_miner/attribute_collection.rb', line 10 def key!(step, attr_name, = {}) find_or_initialize(attr_name).key_for!(step, ) end |