{"id":19840575,"url":"https://github.com/zefer/active_cart_mongoid","last_synced_at":"2025-08-03T12:03:52.509Z","repository":{"id":138713877,"uuid":"1422180","full_name":"zefer/active_cart_mongoid","owner":"zefer","description":"Mongoid persistence for the active_cart gem","archived":false,"fork":false,"pushed_at":"2011-03-24T16:05:30.000Z","size":106,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-05T00:23:31.889Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zefer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-02-28T16:24:25.000Z","updated_at":"2013-06-29T11:50:55.000Z","dependencies_parsed_at":"2023-03-13T10:53:16.449Z","dependency_job_id":null,"html_url":"https://github.com/zefer/active_cart_mongoid","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/zefer/active_cart_mongoid","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zefer%2Factive_cart_mongoid","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zefer%2Factive_cart_mongoid/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zefer%2Factive_cart_mongoid/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zefer%2Factive_cart_mongoid/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zefer","download_url":"https://codeload.github.com/zefer/active_cart_mongoid/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zefer%2Factive_cart_mongoid/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268540450,"owners_count":24266546,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-03T02:00:12.545Z","response_time":2577,"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":"2024-11-12T12:27:24.750Z","updated_at":"2025-08-03T12:03:52.423Z","avatar_url":"https://github.com/zefer.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"active_cart_mongoid\n===================\n\nMongoid storage bolt-on for the [active_cart](http://github.com/madpilot/active_cart) gem\n\nA work-in-progress, any contribution very welcome!\n\nUsage\n=====\n\t\nMixin the MongoidItem into your CartItem (or similar) class, e.g:\n\n\tclass CartItem\n\t  include Mongoid::Document\n\t  include ActiveCart::Items::MongoidItem\n\n\t  # a cart item will always contain a product\n\t  embeds_one :product\n\t  embedded_in :ShoppingCart, :inverse_of =\u003e :items\n\t  \n\t  # you need to override the construtor to ensure the cart item's ID represents the product's ID. otherwise, the cart will always think you are adding a different product and will never increment quantity.\n\t  def initialize(product)\n\t    attrs = {\n\t      :id =\u003e product.id,\n\t      :product =\u003e product\n\t    }\n\t    super(attrs)\n\t  end\n\t\n\t  # this should return the price as it will be serialised in the basket collection, e.g. pence/cents\n\t  def price\n\t\tproduct.price\n\t  end\n\tend\n\t\nExtend the ActiveCart::StorageEngines::MongoidStorage class with a concrete Cart / Basket (or whatever you want to call it) class, e.g.:\n\n\tclass ShoppingCart \u003c ActiveCart::StorageEngines::MongoidStorage\n\t  # you must define the mongoid association to model the cart contents, e.g:\n\t  embeds_many :items, :class_name =\u003e \"Product\"\n\t  # optionally change which collection the carts are stored\n\t  store_in :shopping_baskets\n\tend\n\nThen your cart items can be serialised to a basket\n\n\tinclude ActiveCart\n\tc = Cart.new(ShoppingCart.new)\n\ti = CartItem.new(Product.first)\n\tc.add_to_cart(i)\n\nContributing to active_cart_mongoid\n===================================\n \n* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet\n* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it\n* Fork the project\n* Start a feature/bugfix branch\n* Commit and push until you are happy with your contribution\n* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.\n* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.\n\nCopyright\n=========\n\nCopyright (c) 2011 Joe Roberts. See LICENSE.txt for\nfurther details.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzefer%2Factive_cart_mongoid","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzefer%2Factive_cart_mongoid","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzefer%2Factive_cart_mongoid/lists"}