Class: Alba::Layout
- Inherits:
-
Object
- Object
- Alba::Layout
- Extended by:
- Forwardable
- Defined in:
- lib/alba/layout.rb,
sig/alba/layout.rbs
Overview
Layout serialization
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(file:, inline:) ⇒ Layout
constructor
private
A new instance of Layout.
- #object ⇒ Object
- #params ⇒ generic_hash
- #serializable_hash ⇒ generic_hash
-
#serialize(resource:, serialized_json:, binding:) ⇒ String
private
Serialize within layout.
- #to_h ⇒ generic_hash
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 |
Class Method Details
.def_delegators ⇒ void
This method returns an undefined value.
13 |
# File 'sig/alba/layout.rbs', line 13
def self.def_delegators: (Symbol, *Symbol) -> void
|
Instance Method Details
#object ⇒ Object
8 |
# File 'sig/alba/layout.rbs', line 8
def object: () -> untyped
|
#params ⇒ generic_hash
9 |
# File 'sig/alba/layout.rbs', line 9
def params: () -> generic_hash
|
#serializable_hash ⇒ generic_hash
10 |
# File 'sig/alba/layout.rbs', line 10
def serializable_hash: () -> generic_hash
|
#serialize(resource:, serialized_json:, binding:) ⇒ String
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 |
#to_h ⇒ generic_hash
11 |
# File 'sig/alba/layout.rbs', line 11
def to_h: () -> generic_hash
|