Class: CheeseCloth::Wrapper
- Inherits:
-
Object
- Object
- CheeseCloth::Wrapper
- Defined in:
- lib/cheesecloth/wrapper.rb
Instance Attribute Summary collapse
-
#default_scope_proc ⇒ Object
readonly
Returns the value of attribute default_scope_proc.
-
#filter_list ⇒ Object
readonly
Returns the value of attribute filter_list.
-
#klass ⇒ Object
readonly
Returns the value of attribute klass.
-
#scope ⇒ Object
readonly
Returns the value of attribute scope.
Instance Method Summary collapse
- #assign_and_check_scope(instance) ⇒ Object
- #assign_default_scope_proc(block) ⇒ Object
-
#initialize(klass) ⇒ Wrapper
constructor
A new instance of Wrapper.
- #prepare_and_run(instance) ⇒ Object
- #run(instance) ⇒ Object
Constructor Details
#initialize(klass) ⇒ Wrapper
Returns a new instance of Wrapper.
6 7 8 9 |
# File 'lib/cheesecloth/wrapper.rb', line 6 def initialize(klass) @klass = klass @filter_list = FilterList.new(klass) end |
Instance Attribute Details
#default_scope_proc ⇒ Object (readonly)
Returns the value of attribute default_scope_proc.
4 5 6 |
# File 'lib/cheesecloth/wrapper.rb', line 4 def default_scope_proc @default_scope_proc end |
#filter_list ⇒ Object (readonly)
Returns the value of attribute filter_list.
4 5 6 |
# File 'lib/cheesecloth/wrapper.rb', line 4 def filter_list @filter_list end |
#klass ⇒ Object (readonly)
Returns the value of attribute klass.
4 5 6 |
# File 'lib/cheesecloth/wrapper.rb', line 4 def klass @klass end |
#scope ⇒ Object (readonly)
Returns the value of attribute scope.
4 5 6 |
# File 'lib/cheesecloth/wrapper.rb', line 4 def scope @scope end |
Instance Method Details
#assign_and_check_scope(instance) ⇒ Object
20 21 22 23 |
# File 'lib/cheesecloth/wrapper.rb', line 20 def assign_and_check_scope(instance) @scope ||= default_scope_proc && default_scope_proc.call raise MissingScopeError, self.class unless instance.scope end |
#assign_default_scope_proc(block) ⇒ Object
11 12 13 |
# File 'lib/cheesecloth/wrapper.rb', line 11 def assign_default_scope_proc(block) @default_scope_proc = block end |
#prepare_and_run(instance) ⇒ Object
15 16 17 18 |
# File 'lib/cheesecloth/wrapper.rb', line 15 def prepare_and_run(instance) assign_and_check_scope(instance) run(instance) end |
#run(instance) ⇒ Object
25 26 27 |
# File 'lib/cheesecloth/wrapper.rb', line 25 def run(instance) filter_list.run_filters(instance) end |