Class: Scryglass::ViewWrapper
- Inherits:
-
Object
- Object
- Scryglass::ViewWrapper
- Defined in:
- lib/scryglass/view_wrapper.rb
Instance Attribute Summary collapse
-
#model ⇒ Object
Returns the value of attribute model.
-
#string ⇒ Object
Returns the value of attribute string.
-
#string_lambda ⇒ Object
Returns the value of attribute string_lambda.
Instance Method Summary collapse
-
#initialize(model, string: nil, string_lambda: nil) ⇒ ViewWrapper
constructor
A new instance of ViewWrapper.
- #to_s ⇒ Object
Constructor Details
#initialize(model, string: nil, string_lambda: nil) ⇒ ViewWrapper
Returns a new instance of ViewWrapper.
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/scryglass/view_wrapper.rb', line 7 def initialize(model, string: nil, string_lambda: nil) unless !!string ^ !!string_lambda raise ArgumentError, 'Must provide either `string` or `string_lambda`, ' \ 'but not both.' end self.model = model self.string = string self.string_lambda = string_lambda end |
Instance Attribute Details
#model ⇒ Object
Returns the value of attribute model.
5 6 7 |
# File 'lib/scryglass/view_wrapper.rb', line 5 def model @model end |
#string ⇒ Object
Returns the value of attribute string.
5 6 7 |
# File 'lib/scryglass/view_wrapper.rb', line 5 def string @string end |
#string_lambda ⇒ Object
Returns the value of attribute string_lambda.
5 6 7 |
# File 'lib/scryglass/view_wrapper.rb', line 5 def string_lambda @string_lambda end |
Instance Method Details
#to_s ⇒ Object
18 19 20 21 |
# File 'lib/scryglass/view_wrapper.rb', line 18 def to_s return string if string return string_lambda.call(model) if string_lambda end |