Class: Alba::Layout Private
- Inherits:
-
Object
- Object
- Alba::Layout
- Extended by:
- Forwardable
- Defined in:
- lib/alba/layout.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Layout serialization
Instance Method Summary collapse
-
#initialize(file:, inline:) ⇒ Layout
constructor
private
A new instance of Layout.
-
#serialize(resource:, serialized_json:, binding:) ⇒ Object
private
Serialize within layout.
Constructor Details
#initialize(file:, inline:) ⇒ Layout
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Layout.
16 17 18 19 20 21 22 23 24 |
# File 'lib/alba/layout.rb', line 16 def initialize(file:, inline:) @body = if file check_and_return(file, 'File layout must be a String representing filename', String) elsif inline check_and_return(inline, 'Inline layout must be a Proc returning a Hash or a String', Proc) else raise ArgumentError, 'Layout must be either String or Proc' end end |
Instance Method Details
#serialize(resource:, serialized_json:, binding:) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Serialize within layout
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/alba/layout.rb', line 31 def serialize(resource:, serialized_json:, binding:) @resource = resource @serialized_json = serialized_json if @body.is_a?(String) serialize_within_string_layout(binding) else serialize_within_inline_layout end end |