{"action":"created","issue":{"url":"https://api.github.com/repos/mikenichols/actionizer/issues/14","repository_url":"https://api.github.com/repos/mikenichols/actionizer","labels_url":"https://api.github.com/repos/mikenichols/actionizer/issues/14/labels{/name}","comments_url":"https://api.github.com/repos/mikenichols/actionizer/issues/14/comments","events_url":"https://api.github.com/repos/mikenichols/actionizer/issues/14/events","html_url":"https://github.com/mikenichols/actionizer/issues/14","id":180432320,"number":14,"title":"Default values in inputs_for","user":{"login":"wakproductions","id":1912237,"avatar_url":"https://avatars.githubusercontent.com/u/1912237?v=3","gravatar_id":"","url":"https://api.github.com/users/wakproductions","html_url":"https://github.com/wakproductions","followers_url":"https://api.github.com/users/wakproductions/followers","following_url":"https://api.github.com/users/wakproductions/following{/other_user}","gists_url":"https://api.github.com/users/wakproductions/gists{/gist_id}","starred_url":"https://api.github.com/users/wakproductions/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wakproductions/subscriptions","organizations_url":"https://api.github.com/users/wakproductions/orgs","repos_url":"https://api.github.com/users/wakproductions/repos","events_url":"https://api.github.com/users/wakproductions/events{/privacy}","received_events_url":"https://api.github.com/users/wakproductions/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2016-10-01T02:06:11Z","updated_at":"2016-10-18T21:17:02Z","closed_at":null,"body":"Hey Mike,\r\n\r\nWhat do you think of allowing a default value to be specified in the inputs_for block?"},"comment":{"url":"https://api.github.com/repos/mikenichols/actionizer/issues/comments/254641977","html_url":"https://github.com/mikenichols/actionizer/issues/14#issuecomment-254641977","issue_url":"https://api.github.com/repos/mikenichols/actionizer/issues/14","id":254641977,"user":{"login":"wakproductions","id":1912237,"avatar_url":"https://avatars.githubusercontent.com/u/1912237?v=3","gravatar_id":"","url":"https://api.github.com/users/wakproductions","html_url":"https://github.com/wakproductions","followers_url":"https://api.github.com/users/wakproductions/followers","following_url":"https://api.github.com/users/wakproductions/following{/other_user}","gists_url":"https://api.github.com/users/wakproductions/gists{/gist_id}","starred_url":"https://api.github.com/users/wakproductions/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wakproductions/subscriptions","organizations_url":"https://api.github.com/users/wakproductions/orgs","repos_url":"https://api.github.com/users/wakproductions/repos","events_url":"https://api.github.com/users/wakproductions/events{/privacy}","received_events_url":"https://api.github.com/users/wakproductions/received_events","type":"User","site_admin":false},"created_at":"2016-10-18T21:17:02Z","updated_at":"2016-10-18T21:17:02Z","body":"I've been thinking about this and planned to write a pull request, but it got me thinking maybe the best practice for defaults is to write methods. Here's an example class and the design pattern I'm really starting to like:\r\n\r\n```ruby\r\nmodule Extractor\r\n  class ProcessDomainList\r\n    include Actionizer\r\n\r\n    inputs_for :call do\r\n      optional :offset\r\n      optional :output_stream\r\n    end\r\n\r\n    def call\r\n      output.result = list.map do |domain|\r\n        puts \"Processing domain: #{domain}\"\r\n        {\r\n          \"#{domain}\" => Extractor::ExtractDomainPages.(domain: domain, output_stream: output_stream).result\r\n        }\r\n      end\r\n    end\r\n\r\n    private\r\n\r\n    def list\r\n      CommonCrawlExtractor::DOMAINS_WHITELIST[offset..CommonCrawlExtractor::DOMAINS_WHITELIST.size]\r\n    end\r\n\r\n    def offset\r\n      input.offset || 0\r\n    end\r\n\r\n    def output_stream\r\n      @output_stream ||= input.output_stream || WARC::OutputStream::STDOUT.new\r\n    end\r\n\r\n  end\r\nend\r\n```\r\n\r\nI just set the defaults within the methods named after the optional inputs. This encourages consistency and gives you the opportunity to memoize default logic. What do you think?"}}
{"actor":{"display_login":"wakproductions"}}