I would like to know when is the best time to use mixins against a direct method call.
For example, consider HTTParty. In one example, https://github.com/jnunemaker/httparty/blob/master/examples/basic.rb
you can use HTTParty.get ('http://twitter.com/statuses/public_timeline.json'), or you can create a class that includes HTTParty and then use it as you call HTTParty yourself.
What is the difference with me just by creating something like this:
class Partay
@base_uri = 'http://localhost:3000'
def self.post(endpoint, options)
HTTParty.post(@base_uri + endpoint, options)
end
end
in comparison with this example:
class Partay
include HTTParty
base_uri 'http://localhost:3000'
end
It is true that in such a trivial example, perhaps using include will save more characters, but I would suggest that in a much more complex class this really does not matter.
:
? - ? (, , , ..)? , ( docs , , Enumerable), ? mixin ( )?