lib/nanoc3/base/source_data/layout.rb in nanoc3-3.2.0a2 vs lib/nanoc3/base/source_data/layout.rb in nanoc3-3.2.0a3

- old
+ new

@@ -14,13 +14,10 @@ # @return [String] This layout's identifier, starting and ending with a # slash attr_accessor :identifier - # @return [Time] The time where this layout was last modified - attr_reader :mtime - # Creates a new layout. # # @param [String] raw_content The raw content of this layout. # # @param [Hash] attributes A hash containing this layout's attributes. @@ -30,22 +27,21 @@ # @param [Time, Hash] params Extra parameters. For backwards # compatibility, this can be a Time instance indicating the time when # this layout was last modified (mtime). # # @option params [Time, nil] :mtime (nil) The time when this layout was - # last modified + # last modified. Deprecated; pass the modification time as the `:mtime` + # attribute instead. def initialize(raw_content, attributes, identifier, params=nil) - # Parse params - params ||= {} - params = { :mtime => params } if params.is_a?(Time) - - # Get mtime - @mtime = params[:mtime] - @raw_content = raw_content @attributes = attributes.symbolize_keys @identifier = identifier.cleaned_identifier + + # Set mtime + params ||= {} + params = { :mtime => params } if params.is_a?(Time) + @attributes.merge(:mtime => params[:mtime]) if params[:mtime] end # Requests the attribute with the given key. # # @param [Symbol] key The name of the attribute to fetch. @@ -74,9 +70,14 @@ [ type, self.identifier ] end def inspect "<#{self.class}:0x#{self.object_id.to_s(16)} identifier=#{self.identifier}>" + end + + # @deprecated Access the modification time using `layout[:mtime]` instead. + def mtime + self[:mtime] end end end