{"id":18319751,"url":"https://github.com/redding/much-mixin","last_synced_at":"2025-04-09T14:22:27.767Z","repository":{"id":55102887,"uuid":"46762185","full_name":"redding/much-mixin","owner":"redding","description":"Enhanced mix-in API.","archived":false,"fork":false,"pushed_at":"2022-02-25T15:37:27.000Z","size":30,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-17T13:07:45.944Z","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/redding.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":"2015-11-24T02:37:14.000Z","updated_at":"2021-10-29T19:04:19.000Z","dependencies_parsed_at":"2022-08-14T12:01:05.358Z","dependency_job_id":null,"html_url":"https://github.com/redding/much-mixin","commit_stats":null,"previous_names":["redding/much-plugin"],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/redding%2Fmuch-mixin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/redding%2Fmuch-mixin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/redding%2Fmuch-mixin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/redding%2Fmuch-mixin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/redding","download_url":"https://codeload.github.com/redding/much-mixin/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248054200,"owners_count":21039952,"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-11-05T18:14:09.513Z","updated_at":"2025-04-09T14:22:27.745Z","avatar_url":"https://github.com/redding.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MuchMixin\n\nEnhanced mix-in API.\n\n## Usage\n\n```ruby\nrequre \"much-mixin\"\n\nmodule MyMuchMixin\n  include MuchMixin\n\n  mixin_included do\n    # do some stuff ...\n    # - will be class eval'd in the scope of the receiver of `MyMuchMixin`\n    # - will only be executed once per receiver, no matter how many times\n    #   `MyMuchMixin` is included in that receiver\n  end\nend\n```\n\nMix `MuchMixin` in on mix-ins. Define included hooks using `mixin_included` that will be class eval'd in the scope of the receiver.\n\nThis allows you to define multiple hooks separately and ensures each hook will only be executed once - even if your mix-in is mixed-in multiple times on the same receiver.\n\n### `mixin_class_methods` / `mixin_instance_methods`\n\nMuchMixin provides convenience methods for defining instance/class methods on receivers:\n\n```ruby\nrequre \"much-mixin\"\n\nmodule MyMuchMixin\n  include MuchMixin\n\n  mixin_class_methods do\n    # define some methods ...\n    # - these methods will become class methods on the receiver\n  end\n\n  mixin_instance_methods do\n    # define some methods ...\n    # - these methods will become instance methods on the receiver\n  end\nend\n```\n\n### `after_mixin_included`\n\nThese hooks work just like the `mixin_included` hooks, except they are evaluated _after_ any mix-in class/instance methods have been evaluated. E.g. use this to call a class method that the mix-in defines.\n\n```ruby\nrequre \"much-mixin\"\n\nmodule MyMuchMixin\n  include MuchMixin\n\n  after_mixin_included do\n    configure_the_mixin\n  end\n\n  mixin_class_methods do\n    def configure_the_mixin\n      # ...\n    end\n  end\nend\n```\n\n## Example\n\n```ruby\nrequre \"much-mixin\"\n\nmodule AnotherMixin\n  def another\n    \"another\"\n  end\nend\n\nmodule MyMuchMixin\n  include MuchMixin\n\n  mixin_included do\n    include AnotherMixin\n  end\n\n  mixin_class_methods do\n    def a_class_method\n      \"a-class-method\"\n    end\n  end\n\n  mixin_instance_methods do\n    def an_instance_method\n      \"an-instance-method\"\n    end\n  end\nend\n\nclass MyClass\n  include MyMuchMixin\nend\n\nmy_class = MyClass.new\nmy_class.another            # =\u003e \"another\"\nmy_class.an_instance_method # =\u003e \"an-instance-method\"\nMyClass.a_class_method      # =\u003e \"a-class-method\"\n```\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n    gem \"much-mixin\"\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install much-mixin\n\n## Contributing\n\n1. Fork it\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Added some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create new Pull Request\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fredding%2Fmuch-mixin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fredding%2Fmuch-mixin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fredding%2Fmuch-mixin/lists"}