{"id":25381623,"url":"https://github.com/drabiter/caphe","last_synced_at":"2025-04-09T12:15:19.048Z","repository":{"id":57194135,"uuid":"20750583","full_name":"drabiter/caphe","owner":"drabiter","description":"Various model helper for CoffeeScript","archived":false,"fork":false,"pushed_at":"2014-09-16T02:21:55.000Z","size":356,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-15T18:19:54.452Z","etag":null,"topics":["coffeescript","mixins","oop","proof-of-concept"],"latest_commit_sha":null,"homepage":"http://drabiter.com/caphe/","language":"CoffeeScript","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/drabiter.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOGS","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":"2014-06-12T01:37:20.000Z","updated_at":"2016-11-02T03:30:16.000Z","dependencies_parsed_at":"2022-09-06T17:30:32.334Z","dependency_job_id":null,"html_url":"https://github.com/drabiter/caphe","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drabiter%2Fcaphe","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drabiter%2Fcaphe/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drabiter%2Fcaphe/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drabiter%2Fcaphe/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/drabiter","download_url":"https://codeload.github.com/drabiter/caphe/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248036056,"owners_count":21037093,"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":["coffeescript","mixins","oop","proof-of-concept"],"created_at":"2025-02-15T06:22:47.466Z","updated_at":"2025-04-09T12:15:19.031Z","avatar_url":"https://github.com/drabiter.png","language":"CoffeeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"Caphe\n=====\n\n[![Build Status][travis-img]][travis-url]\n[![Coverage Status][coveralls-img]][coveralls-url]\n[![NPM Download][npm-img]][npm-url]\n\n[travis-img]: http://img.shields.io/travis/drabiter/caphe.svg?style=flat-square\n[travis-url]: https://travis-ci.org/drabiter/caphe\n[coveralls-img]: http://img.shields.io/coveralls/drabiter/caphe.svg?style=flat-square\n[coveralls-url]: https://coveralls.io/r/drabiter/caphe?branch=master\n[npm-img]: http://img.shields.io/npm/v/npm.svg?style=flat-square\n[npm-url]: https://www.npmjs.org/package/caphe\n\n[![NPM](https://nodei.co/npm/caphe.png?downloads=true\u0026stars=true)](https://nodei.co/npm/caphe/)\n\nVarious design utils for [htpp://coffeescript.org](CoffeeScript). Implementation of Reg Braithwaite's [article](http://raganwald.com/2014/04/10/mixins-forwarding-delegation.html).\n\n## Features\n\n**\u003e mixin** consumer, modules...\n\nMix modules' methods to the model.\n```coffeescript\nclass Person\n\nperson = new Person()\n\nTalkable =\n  speak: -\u003e\n    console.log \"Yeah!\"\n\nMoveable =\n  walk: (speed) -\u003e\n    console.log \"Walk by #{speed}\"\n  run: (speed) -\u003e\n    console.log \"Run by #{speed}\"\n\nCaphe.mixin(person, Talkable, Moveable)\n\n\nperson.speak() # \"Yeah!\"\nperson.walk(8) # \"Walk by 8\"\nperson.run(5)  # \"Run by 5\"\n```\n----------\n\n**\u003e include** module[, names...]\n\nLike mixin but do it Ruby style. Optionally, specify name of methods that will be included\n```coffeescript\nTalkable =\n  speak: -\u003e\n    console.log \"Yeah!\"\n\nclass Person extends Caphe\n  @include Talkable\n  @include Moveable, 'run'\n\nperson = new Person()\n\n\nperson.speak() # \"Yeah!\"\nperson.run(6)  # \"Run by 6\"\n\nperson.walk(4) # undefined\n```\n----------\n\n**\u003e attrAccessor** names...\n\nCreate getter \u0026 setter methods in Ruby style and hide the properties from public access.\n```coffeescript\nclass Person extends Caphe\n  @attrAccessor \"name\", \"age\"\n\n  constructor: (@job) -\u003e\n\n\nperson = new Person(\"Bar\")\nperson.setName(\"Foo\")\nperson.getName()        # Foo\nperson.name             # undefined\nperson.getAge()         # undefined\nperson.setAge(5)\nperson.getAge()         # 5\nperson.age              # undefined\nperson.job              # Bar\n```\n----------\n\n**\u003e CONST** name: value, ...\n\nCreate constant getters in prototype level.\n```coffeescript\nclass Person extends Caphe\n  @CONST EYE: 2, SPECIES: 'homo sapiens'\n\n\nPerson::EYE()      # 2\nPerson::SPECIES()  # homo sapiens\n```\n----------\n\n**\u003e forward** consumer, providers...\n\nMixin with late bound. The forwarded methods have each own module as their context.\n```coffeescript\nmodule.foo = -\u003e console.log \"a\"\nmodule.bar = -\u003e console.log @name\nCaphe.forward(person, module)\n\n\nperson.foo()  # a\nperson.bar()  # undefined\n\nmodule.bar = -\u003e console.log \"b\"\nperson.bar()  # b\n```\n----------\n\n**\u003e delegate** consumer, providers...\n\nLike `#forward`, but the forwarded methods have the consumer as their context.\n```coffeescript\nperson.name = \"John\"\nmodule.foo = -\u003e console.log \"a\"\nmodule.bar = -\u003e console.log @name\nCaphe.delegate(person, module)\n\n\nperson.foo()  # a\nperson.bar()  # John\n\nmodule.foo = -\u003e console.log \"b\"\nperson.foo()  # b\n```\n----------\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdrabiter%2Fcaphe","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdrabiter%2Fcaphe","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdrabiter%2Fcaphe/lists"}