Module: Synchronisable::DSL::Macro Private

Extended by:
ActiveSupport::Concern
Included in:
Association, Synchronizer
Defined in:
lib/synchronisable/dsl/macro.rb,
lib/synchronisable/dsl/macro/method.rb,
lib/synchronisable/dsl/macro/attribute.rb,
lib/synchronisable/dsl/macro/expression.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Allows to define DSL-like attributes and methods. to be used in target class/module.

Examples:

Common use cases

class Foo
  include Synchronisable::DSL::Macro

  attribute :bar, default: 1
  attribute :blah, default: -> { bar * 2 }
  attribute :x, :y, :z
  attribute :f, -> {
    ...
  }
  attribute :w, converter: ->(h) { x.with_indifferent_access }
  method :sqr, default: ->(x) { x * x }
  method :sqrt, :sin, :cos, default: -> { raise NotImplementedError }
end

class Bar < Foo
  bar 4
  blah "blah blah"

  sqr do |x|
    x * x
  end
end

See Also:

Defined Under Namespace

Modules: ClassMethods Classes: Attribute, Expression, Method