Sha256: 095a2d0cad14ebf5682c4e0abbb886131cfa64c63daee519cbd51b2a3338d509
Contents?: true
Size: 1.22 KB
Versions: 1
Compression:
Stored size: 1.22 KB
Contents
module Axel module Payload class Metadata < Base root_node :metadata def paged? total_pages > 1 end def total_pages raw = pagination_settings["total_pages"].to_i raw == 0 ? 1 : raw end def merge!(other_object) tap do @attributes.merge! mergeable_from(other_object) end end def merge(other_object) #self.class.new(attributes).tap do |c| dup.tap do |c| c.merge!(mergeable_from(other_object)) end end def dup(*args) super.tap do |d| d.instance_variable_set "@attributes", @attributes.clone end end def clone(*args) super.tap do |c| c.instance_variable_set "@attributes", @attributes.clone end end def pagination_settings fetch("pagination", {}) end private :pagination_settings def mergeable_from(object) if object.respond_to?(:attributes) && object.attributes.is_a?(Hash) object.attributes elsif object.is_a? Hash object else {} # unmergeable, should think about erroring end end private :mergeable_from end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
axel-0.0.1 | app/models/axel/payload/metadata.rb |