Releases: joelmoss/spaced
Releases · joelmoss/spaced
v0.5.0
What's Changed
- Predicate methods now accept arguments.
- Fix a typo by @vassilevsky in #1
New Contributors
- @vassilevsky made their first contribution in #1
Full Changelog: v0.4.0...v0.5.0
0.4.0
Changes
Bang and predicate methods can now be defined using an underscore as the method name. This is now the preferred way.
namespace :tweet do
def _?
# ...
end
def _!
# ...
end
end
And you can now also use the name of the defined namespace:
namespace :tweet do
def tweet?
# ...
end
def tweet!
# ...
end
end
Full Changelog: v0.3.1...v0.4.0
0.3.0
Features
Magic bang and predicate methods
If you define a call
method in your namespaced class, you can then conveniently call that with a bang method...
class User < Spaced::Base
include Spaced
namespace :tweet do
def call(content)
create_tweet content
end
end
end
user = User.new
user.tweet! # Will call the `#call` method with whatever arguments you give it.
There is also an equivalent predicate
method...
namespace :tweet do
def predicate
false
end
end
user = User.new
user.tweet? # Will call the `#predicate` method.
Fixes
Predefined classes must now subclass the Spaced::Base
calls. This is to ensure that all functionality is maintained with no extra effort.
class User < Spaced::Base; end