{"action":"created","issue":{"url":"https://api.github.com/repos/egonSchiele/contracts.ruby/issues/176","labels_url":"https://api.github.com/repos/egonSchiele/contracts.ruby/issues/176/labels{/name}","comments_url":"https://api.github.com/repos/egonSchiele/contracts.ruby/issues/176/comments","events_url":"https://api.github.com/repos/egonSchiele/contracts.ruby/issues/176/events","html_url":"https://github.com/egonSchiele/contracts.ruby/issues/176","id":93672147,"number":176,"title":"Cannot call Contract in AS#included block","user":{"login":"PikachuEXE","id":1018543,"avatar_url":"https://avatars.githubusercontent.com/u/1018543?v=3","gravatar_id":"","url":"https://api.github.com/users/PikachuEXE","html_url":"https://github.com/PikachuEXE","followers_url":"https://api.github.com/users/PikachuEXE/followers","following_url":"https://api.github.com/users/PikachuEXE/following{/other_user}","gists_url":"https://api.github.com/users/PikachuEXE/gists{/gist_id}","starred_url":"https://api.github.com/users/PikachuEXE/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PikachuEXE/subscriptions","organizations_url":"https://api.github.com/users/PikachuEXE/orgs","repos_url":"https://api.github.com/users/PikachuEXE/repos","events_url":"https://api.github.com/users/PikachuEXE/events{/privacy}","received_events_url":"https://api.github.com/users/PikachuEXE/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/egonSchiele/contracts.ruby/labels/bug","name":"bug","color":"fc2929"},{"url":"https://api.github.com/repos/egonSchiele/contracts.ruby/labels/need/details","name":"need/details","color":"fef2c0"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":13,"created_at":"2015-07-08T01:55:28Z","updated_at":"2015-09-05T00:38:42Z","closed_at":null,"body":"# Env\r\nMRI `2.2.2` or `2.2.3`\r\n\r\n# Code\r\nI got the following code:\r\n```ruby\r\nclass Something < ActiveRecord::Base\r\n  module WithSettings\r\n    extend ActiveSupport::Concern\r\n\r\n    def self.included(base)\r\n      base.class_eval do\r\n        include Contracts\r\n\r\n        Contract None => ArrayOf[String]\r\n        def emails\r\n          #...\r\n        end\r\n      end\r\n    end\r\n  end\r\nend\r\n```\r\nMessage from application: undefined method `Contract' for Class:Class (NoMethodError)\r\n\r\n# Updates\r\n**Update 1**: Even after I have removed `ActiveSupport::Concern` usage (and switch to `Module#included`, it's still failing. So I updated the code to ensure it's not AS related.\r\n**Update 2**: Included Ruby versions\r\n"},"comment":{"url":"https://api.github.com/repos/egonSchiele/contracts.ruby/issues/comments/137887687","html_url":"https://github.com/egonSchiele/contracts.ruby/issues/176#issuecomment-137887687","issue_url":"https://api.github.com/repos/egonSchiele/contracts.ruby/issues/176","id":137887687,"user":{"login":"waterlink","id":609046,"avatar_url":"https://avatars.githubusercontent.com/u/609046?v=3","gravatar_id":"","url":"https://api.github.com/users/waterlink","html_url":"https://github.com/waterlink","followers_url":"https://api.github.com/users/waterlink/followers","following_url":"https://api.github.com/users/waterlink/following{/other_user}","gists_url":"https://api.github.com/users/waterlink/gists{/gist_id}","starred_url":"https://api.github.com/users/waterlink/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/waterlink/subscriptions","organizations_url":"https://api.github.com/users/waterlink/orgs","repos_url":"https://api.github.com/users/waterlink/repos","events_url":"https://api.github.com/users/waterlink/events{/privacy}","received_events_url":"https://api.github.com/users/waterlink/received_events","type":"User","site_admin":false},"created_at":"2015-09-05T00:38:41Z","updated_at":"2015-09-05T00:38:41Z","body":"So if you say, that code is AS/AR independent, can it be rewritten like this?:\r\n\r\n```ruby\r\nclass Something\r\n  module WithSettings\r\n    def self.included(base)\r\n      base.class_eval do\r\n        include Contracts\r\n\r\n        Contract None => ArrayOf[String]\r\n        def emails\r\n          #...\r\n        end\r\n      end\r\n    end\r\n  end\r\nend\r\n```\r\n\r\n?"}}