{"id":15406484,"url":"https://github.com/odlp/adapter-pattern-example","last_synced_at":"2025-04-06T12:13:29.547Z","repository":{"id":81161627,"uuid":"112474548","full_name":"odlp/adapter-pattern-example","owner":"odlp","description":null,"archived":false,"fork":false,"pushed_at":"2018-01-19T12:29:21.000Z","size":5,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-02-12T17:49:54.972Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/odlp.png","metadata":{"files":{"readme":"README.md","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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-11-29T12:47:19.000Z","updated_at":"2017-11-29T12:47:38.000Z","dependencies_parsed_at":null,"dependency_job_id":"f8d2789a-1be8-4d61-bfaa-4db4233ce72f","html_url":"https://github.com/odlp/adapter-pattern-example","commit_stats":{"total_commits":6,"total_committers":2,"mean_commits":3.0,"dds":"0.16666666666666663","last_synced_commit":"ede54bfdf52f5059c47b7e268bf90e81344c8eda"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/odlp%2Fadapter-pattern-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/odlp%2Fadapter-pattern-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/odlp%2Fadapter-pattern-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/odlp%2Fadapter-pattern-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/odlp","download_url":"https://codeload.github.com/odlp/adapter-pattern-example/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247478331,"owners_count":20945266,"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-01T16:23:17.173Z","updated_at":"2025-04-06T12:13:29.512Z","avatar_url":"https://github.com/odlp.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Adapter pattern\n\nRiffing on the adapter pattern from:\n[http://legacy.new-bamboo.co.uk/blog/2008/02/05/micro-patterns-in-ruby/](http://legacy.new-bamboo.co.uk/blog/2008/02/05/micro-patterns-in-ruby/)\n\nTakes a different approach of finding constants within a module that respond to `#match?`, avoiding inheritance and class variables.\n\n## Reference implementation\n\nFrom the blog post:\n\n```ruby\n# = The superclass / factory\nclass ServiceParser\n  # We register adapters into this class variable\n  #\n  @@adapters = []\n\n  # class reader\n  #\n  def self.adapters\n    @@adapters\n  end\n\n  # Factory method here, se below...\n  #\nend\n\n# = An example subclass / adapter\nclass FlickrAdapter \u003c ServiceParser\n  def initialize( url)\n\n  end\n\n  # API methods\n  #\n  def thumbnail\n    # do something clever here...\n  end\n\n  # register ourselves with the Factory\n  #\n  ServiceParser.adapters \u003c\u003c [self, /flickr\\.com/]\nend\n```\n\nDifferences with this implementation:\n\n- No `@@adapters` class variable\n- Adapters don't need to add themselves into the `@@adapters` array (`ServiceParser.adapters \u003c\u003c`)\n\n## Getting started\n\n```\nbundle install\nbundle exec rspec\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fodlp%2Fadapter-pattern-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fodlp%2Fadapter-pattern-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fodlp%2Fadapter-pattern-example/lists"}