Class: Brandmaker::VariableCollection
- Inherits:
-
Array
- Object
- Array
- Brandmaker::VariableCollection
- Defined in:
- lib/brandmaker/variable_collection.rb
Instance Method Summary collapse
- #find_by_purpose(purpose) ⇒ Object
- #find_by_technical_name(technical_name) ⇒ Object
-
#initialize(variables, create = true) ⇒ VariableCollection
constructor
A new instance of VariableCollection.
- #unpurposed ⇒ Object
Constructor Details
#initialize(variables, create = true) ⇒ VariableCollection
Returns a new instance of VariableCollection.
4 5 6 7 8 9 10 |
# File 'lib/brandmaker/variable_collection.rb', line 4 def initialize variables, create = true if create super variables.map { |var| Brandmaker::Variable.new(var) } else super variables end end |
Instance Method Details
#find_by_purpose(purpose) ⇒ Object
16 17 18 19 20 |
# File 'lib/brandmaker/variable_collection.rb', line 16 def find_by_purpose(purpose) find do |variable| variable.purpose == purpose end || raise("#{purpose} is not configured for this job") end |
#find_by_technical_name(technical_name) ⇒ Object
12 13 14 |
# File 'lib/brandmaker/variable_collection.rb', line 12 def find_by_technical_name(technical_name) find { |variable| variable.technical_name == technical_name } end |
#unpurposed ⇒ Object
22 23 24 |
# File 'lib/brandmaker/variable_collection.rb', line 22 def unpurposed VariableCollection.new self.select { |var| var.purpose.blank? }, false end |