Skip to content

Releases: joelmoss/spaced

v0.5.0

18 Apr 15:23
Compare
Choose a tag to compare

What's Changed

  • Predicate methods now accept arguments.
  • Fix a typo by @vassilevsky in #1

New Contributors

Full Changelog: v0.4.0...v0.5.0

0.4.0

06 Dec 13:51
Compare
Choose a tag to compare

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

05 Oct 19:35
Compare
Choose a tag to compare

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

0.2.0

30 May 08:49
Compare
Choose a tag to compare

New features

  • Can now pass a class to spaced
class Daddy
  def full_name
    "Daddy Moss"
  end
end

class User
  include Spaced

  namespace :dad, Dad
end