Class: Quickbooks::Options
Overview
A collection of Option objects. Can validate that a given object contains all required options and allowed values in this collection.
Class Method Summary collapse
Instance Method Summary collapse
- #<<(option) ⇒ Object
- #[](name) ⇒ Object
- #defaults ⇒ Object
- #delete(name) ⇒ Object
- #include?(name) ⇒ Boolean
- #validate(object) ⇒ Object
Class Method Details
Instance Method Details
#<<(option) ⇒ Object
13 14 15 |
# File 'lib/quickbooks/option.rb', line 13 def <<(option) << option end |
#[](name) ⇒ Object
30 31 32 33 |
# File 'lib/quickbooks/option.rb', line 30 def [](name) name = name.to_s .select {|option| option.name == name}[0] end |
#defaults ⇒ Object
26 27 28 |
# File 'lib/quickbooks/option.rb', line 26 def defaults .inject({}) {|h,option| h[option.name.to_s] = option.default if option.default && option.required?; h} end |
#delete(name) ⇒ Object
35 36 37 |
# File 'lib/quickbooks/option.rb', line 35 def delete(name) .reject! {|a| a.name == name} end |
#include?(name) ⇒ Boolean
22 23 24 |
# File 'lib/quickbooks/option.rb', line 22 def include?(name) .any? {|option| option.name == name} end |
#validate(object) ⇒ Object
17 18 19 20 |
# File 'lib/quickbooks/option.rb', line 17 def validate(object) puts "Validating #{object.inspect}!" if $DEBUG .check_all? { |option| option.validate(object) } end |