{"id":31009382,"url":"https://github.com/robhurring/cloneable","last_synced_at":"2026-07-22T16:32:06.053Z","repository":{"id":779018,"uuid":"470600","full_name":"robhurring/cloneable","owner":"robhurring","description":"An ActiveRecord plugin that clones models (acts_as_cloneable)","archived":false,"fork":false,"pushed_at":"2010-01-18T14:28:32.000Z","size":80,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-09-13T04:40:48.311Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://blog.ubrio.us","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/robhurring.png","metadata":{"files":{"readme":"README.rdoc","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2010-01-13T17:19:14.000Z","updated_at":"2016-04-06T18:42:02.000Z","dependencies_parsed_at":"2022-08-16T10:50:38.722Z","dependency_job_id":null,"html_url":"https://github.com/robhurring/cloneable","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/robhurring/cloneable","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robhurring%2Fcloneable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robhurring%2Fcloneable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robhurring%2Fcloneable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robhurring%2Fcloneable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/robhurring","download_url":"https://codeload.github.com/robhurring/cloneable/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robhurring%2Fcloneable/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35769887,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-07-20T02:08:10.276Z","status":"online","status_checked_at":"2026-07-22T02:00:06.236Z","response_time":124,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-09-13T04:34:43.499Z","updated_at":"2026-07-22T16:32:06.036Z","avatar_url":"https://github.com/robhurring.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"= About\n\nSimple cloneable interface for ActiveRecord that allows you to call #clone! on a record and have it\nreplicate itself to another object and save itsef. supports basic association cloneing by calling\nclone! on each association you specify using +options[:with]+\n\nThis was created for a specific reason (archiving some records when the tables are flushed with current data), and hasn't really been \ntested or built out to support a wide range of uses. This is in an early BETA state and hasn't been fully tested. \nValidation and association failures will _not_ roll back the clone!, this can be a huge limitation currently. (Hopefully I can get this fixed in an upcoming release)\n\nAuthor:: Rob Hurring (rob at zerobased dot com)\nDate:: 01/12/2010\nHomepage:: http://blog.ubrio.us\nCopyright:: 2010 Zerobased, LLC\nLicense:: DWTFYWWI\n\n=== TODO\n\n* add transactions and rollback when associations/objects fail to save?\n* handle validation failures?\n\n=== Example\n  \n  # Your master records\n  class Company\n    has_many :employees, :dependent =\u003e :destroy\n    # Our Archive::Company has a +company_name+ attribute, while we are using a +name+ attribute. We also don't want to include\n    # our +bank_details+ in the archive.\n    cloneable :to =\u003e ::Archive::Company, :map =\u003e {:name =\u003e :company_name}, :exclude =\u003e [:bank_details], :with =\u003e :employees\n    \n    # After we remove a company, archive it along with all the employees\n    after_destroy :clone!\n  end\n\n  class Employee\n    belongs_to :company\n    cloneable :to =\u003e ::Archive::Employee, :include =\u003e [:calculated_worth], :map =\u003e {:full_name =\u003e :name}\n\n    # some dynamic method that we want to store. our Archive::Employee model will have a +calculated_worth+ attribute\n    def calculated_worth\n      1_000_000\n    end\n\n    # we have first_name \u0026 last_name attributes, our Archive::Employee model only has a +name+ attribute.\n    def full_name\n      \"#{first_name} #{last_name}\"\n    end\n  end\n\n  # Some models based out of another database (or table)\n  module Archive\n    class Company\n      has_many :employees\n    end\n\n    class Employee\n      belongs_to :company\n    end\n  end","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobhurring%2Fcloneable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frobhurring%2Fcloneable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobhurring%2Fcloneable/lists"}