Class: Exhibitionist::Base
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Exhibitionist::Base
- Defined in:
- lib/exhibitionist/base.rb
Class Method Summary collapse
- .applicable_to?(object) ⇒ Boolean
- .applies_if(&block) ⇒ Object
- .applies_unless(&block) ⇒ Object
- .exhibit_if_applicable(object) ⇒ Object
Instance Method Summary collapse
Class Method Details
.applicable_to?(object) ⇒ Boolean
9 10 11 12 13 14 15 |
# File 'lib/exhibitionist/base.rb', line 9 def applicable_to?(object) if @condition return @condition.yield(object) else false end end |
.applies_if(&block) ⇒ Object
21 22 23 |
# File 'lib/exhibitionist/base.rb', line 21 def applies_if(&block) @condition = block end |
.applies_unless(&block) ⇒ Object
25 26 27 |
# File 'lib/exhibitionist/base.rb', line 25 def applies_unless(&block) @conditions = Proc.new { |object| !(block.yield(object)) } end |
.exhibit_if_applicable(object) ⇒ Object
17 18 19 |
# File 'lib/exhibitionist/base.rb', line 17 def exhibit_if_applicable(object) applicable_to?(object) ? self.new(object) : object end |
Instance Method Details
#class ⇒ Object
4 5 6 |
# File 'lib/exhibitionist/base.rb', line 4 def class __getobj__.class end |