Class: MindReader
- Inherits:
-
Object
- Object
- MindReader
- Defined in:
- lib/mind_reader.rb
Defined Under Namespace
Classes: ConfigurableObject
Instance Attribute Summary collapse
-
#retrieve_all_when_no_value_is_given ⇒ Object
Returns the value of attribute retrieve_all_when_no_value_is_given.
Instance Method Summary collapse
- #execute(pairs) ⇒ Object
-
#initialize(klass) {|@configuration| ... } ⇒ MindReader
constructor
A new instance of MindReader.
Constructor Details
#initialize(klass) {|@configuration| ... } ⇒ MindReader
Returns a new instance of MindReader.
5 6 7 8 9 10 |
# File 'lib/mind_reader.rb', line 5 def initialize(klass) @klass = klass @retrieve_all_when_no_value_is_given = false @configuration = ConfigurableObject.new yield @configuration if block_given? end |
Instance Attribute Details
#retrieve_all_when_no_value_is_given ⇒ Object
Returns the value of attribute retrieve_all_when_no_value_is_given.
12 13 14 |
# File 'lib/mind_reader.rb', line 12 def retrieve_all_when_no_value_is_given @retrieve_all_when_no_value_is_given end |
Instance Method Details
#execute(pairs) ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/mind_reader.rb', line 14 def execute(pairs) @pairs = pairs process if @pairs.present? || @clause.first.present? @klass.where(@pairs).where(*@clause.try(:flatten)) else retrieve_all_when_no_value_is_given ? @klass.find(:all) : nil end end |