Class: Errata
- Inherits:
-
Object
- Object
- Errata
- Defined in:
- lib/errata.rb,
lib/errata/erratum.rb,
lib/errata/version.rb,
lib/errata/erratum/delete.rb,
lib/errata/erratum/reject.rb,
lib/errata/erratum/replace.rb,
lib/errata/erratum/simplify.rb,
lib/errata/erratum/truncate.rb,
lib/errata/erratum/transform.rb
Defined Under Namespace
Classes: Erratum
Constant Summary collapse
- ERRATUM_TYPES =
%w{delete replace simplify transform truncate reject}
- VERSION =
'1.0.2'
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #correct!(row) ⇒ Object
- #corrections ⇒ Object
- #errata ⇒ Object
-
#initialize(options = {}) ⇒ Errata
constructor
Arguments *
'responder'
(required) - normally you pass this something like Guru.new, which should respond to questions like #is_a_bentley?. - #rejections ⇒ Object
- #rejects?(row) ⇒ Boolean
- #responder ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Errata
Arguments
-
'responder'
(required) - normally you pass this something like Guru.new, which should respond to questions like #is_a_bentley?. If you pass a string, it will be lazily constantized and a new object initialized from it; for example, ‘Guru’ will lead to ‘Guru’.constantize.new. -
'table'
- takes something that acts like a RemoteTable
If and only if you don’t pass 'table'
, all other options will be passed to a new RemoteTable (for example, 'url'
, etc.)
22 23 24 25 |
# File 'lib/errata.rb', line 22 def initialize( = {}) @options = .dup @options.stringify_keys! end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
16 17 18 |
# File 'lib/errata.rb', line 16 def @options end |
Instance Method Details
#correct!(row) ⇒ Object
35 36 37 38 |
# File 'lib/errata.rb', line 35 def correct!(row) corrections.each { |erratum| erratum.correct!(row) } nil end |
#corrections ⇒ Object
53 54 55 |
# File 'lib/errata.rb', line 53 def corrections errata.select { |erratum| not erratum.is_a? ::Errata::Erratum::Reject } end |
#errata ⇒ Object
40 41 42 43 44 45 46 47 |
# File 'lib/errata.rb', line 40 def errata @errata ||= (['table'] ? ['table'] : ::RemoteTable.new(.except('responder'))).inject([]) do |memo, erratum_description| if ERRATUM_TYPES.include? erratum_description['action'] memo.push "::Errata::Erratum::#{erratum_description['action'].camelcase}".constantize.new self, erratum_description end memo end end |
#rejections ⇒ Object
49 50 51 |
# File 'lib/errata.rb', line 49 def rejections errata.select { |erratum| erratum.is_a? ::Errata::Erratum::Reject } end |
#rejects?(row) ⇒ Boolean
31 32 33 |
# File 'lib/errata.rb', line 31 def rejects?(row) rejections.any? { |erratum| erratum.targets?(row) } end |
#responder ⇒ Object
27 28 29 |
# File 'lib/errata.rb', line 27 def responder ['responder'].is_a?(::String) ? ['responder'].constantize.new : ['responder'] end |