lib/alba/layout.rb in alba-3.0.3 vs lib/alba/layout.rb in alba-3.1.0

- old
+ new

@@ -10,20 +10,20 @@ def_delegators :@resource, :object, :params, :serializable_hash, :to_h # @param file [String] name of the layout file # @param inline [Proc] a proc returning JSON string or a Hash representing JSON def initialize(file:, inline:) - if file - raise ArgumentError, 'File layout must be a String representing filename' unless file.is_a?(String) + @body = if file + raise ArgumentError, 'File layout must be a String representing filename' unless file.is_a?(String) - @body = file - elsif inline - raise ArgumentError, 'Inline layout must be a Proc returning a Hash or a String' unless inline.is_a?(Proc) + file + elsif inline + raise ArgumentError, 'Inline layout must be a Proc returning a Hash or a String' unless inline.is_a?(Proc) - @body = inline - else - raise ArgumentError, 'Layout must be either String or Proc' - end + inline + else + raise ArgumentError, 'Layout must be either String or Proc' + end end # Serialize within layout # # @param resource [Alba::Resource] the original resource calling this layout