module Milestoner::Syndication::Shared

Provides shared functionality for refinements.

Public Instance Methods

build(**attributes) click to toggle source
# File lib/milestoner/syndication/shared.rb, line 13
def build(**attributes)
  node = public_send :"new_#{kind}"
  attributes.each { |key, value| node.public_send :"#{key}=", value }
end
build_for(collection, **) click to toggle source
# File lib/milestoner/syndication/shared.rb, line 9
def build_for(collection, **)
  collection.each { |attributes| build(**attributes.transform_keys(**)) }
end
kind() click to toggle source
# File lib/milestoner/syndication/shared.rb, line 20
def kind
  self.class.name.downcase.split("::").last.sub("categories", "category").delete_suffix("s")
end
merge(**attributes) click to toggle source
# File lib/milestoner/syndication/shared.rb, line 7
  def merge(**attributes) = attributes.each { |key, value| public_send :"#{key}=", value }

  def build_for(collection, **)
    collection.each { |attributes| build(**attributes.transform_keys(**)) }
  end

  def build(**attributes)
    node = public_send :"new_#{kind}"
    attributes.each { |key, value| node.public_send :"#{key}=", value }
  end

  private

  def kind
    self.class.name.downcase.split("::").last.sub("categories", "category").delete_suffix("s")
  end
end