{"id":16813289,"url":"https://github.com/ivanvc/cooler","last_synced_at":"2025-03-17T11:24:35.660Z","repository":{"id":5871901,"uuid":"7089270","full_name":"ivanvc/cooler","owner":"ivanvc","description":null,"archived":false,"fork":false,"pushed_at":"2013-01-03T04:33:20.000Z","size":156,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-23T20:53:20.176Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/ivanvc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-12-10T07:29:17.000Z","updated_at":"2017-05-31T01:14:30.000Z","dependencies_parsed_at":"2022-08-31T15:26:09.241Z","dependency_job_id":null,"html_url":"https://github.com/ivanvc/cooler","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivanvc%2Fcooler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivanvc%2Fcooler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivanvc%2Fcooler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivanvc%2Fcooler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ivanvc","download_url":"https://codeload.github.com/ivanvc/cooler/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244022638,"owners_count":20385133,"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","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-10-13T10:25:52.527Z","updated_at":"2025-03-17T11:24:35.630Z","avatar_url":"https://github.com/ivanvc.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cimg src=\"http://i.imgur.com/qiNrL.jpg\" alt=\"Cooler\" align=\"right\"\u003e\n\n# Cooler\n\n_The Good-Hearted Leader_\n\n\u003e Cooler Howard Smith has an outgoing and mellow personality and always keeps\n\u003e his head up even in the most daring situations. He is smart, laid-back,\n\u003e friendly, witty, and usually optimistic even when things get serious.\n\nA mini ORM, agnostic to key value store databases.\n\nIf you're in a hurry, and need to define some models that should be persisted,\nin any Key-Value Store Database, this is the right gem.\n\n## Installation\n\nAdd `gem 'cooler'` to your Gemfile.\n\n## Define Adapter's set, get and delete\n\nIn an initializer, you'll need to specify how to set, get and delete a key.\nLet's say that you use Redis, then you want to do something similar to:\n\n```ruby\nredis = Redis.new\n\nCooler::Adapater.set = -\u003e(key, value) { redis.set(key, value.to_json) }\nCooler::Adapater.get = -\u003e(key) do\n  result = Bloodhound.redis.get(key) and JSON.parse(result)\nend\nCooler::Adapater.delete = -\u003e(key) { redis.del(key) }\n```\n\nThat's it.\n\n## Define your models\n\nDefining a model is as easy as 1, 2, 3.\n\n```ruby\n# A model should inherit from Struct, attributes defined there are PERSISTED\n# in the database.\nclass User \u003c Struct.new(:login, :age, :encrypted_password, :created_at)\n  # You must include Cooler::Model\n  include Cooler::Model\n\n  # Any attribute accessor, or instance variables, are NOT STORED in the\n  # database, however you can  initialize an object with these attributes.\n  attr_accessor :password\n\n  # You can set defaults for any of the attributes.\n  default :age, 18\n  default :encrypted_password,\n    -\u003e(user) { Digest::MD5.hexdigest(user.password) }\n  default :created_at, -\u003e { Time.now.utc }\n\n  # To define the key for a Model, you need to pass a block, and return an\n  # String that will be the key to store the object.\n  key { |user| \"user_#{user.login}\" }\nend\n\n# You can create a new instance, passing its atributes:\nuser = User.new(login: 'cooler', age: 20, password: 'im_cooler')\nuser.save\n\n# You can also get any stored object, passing a Hash as argument, or\n# specifying the exact key.\nuser = User.get(login: 'cooler') # or User.get('user_cooler')\nuser.age = 10\nuser.save\n```\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fivanvc%2Fcooler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fivanvc%2Fcooler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fivanvc%2Fcooler/lists"}