Module: Ducktape

Defined in:
lib/ducktape/version.rb,
lib/ducktape/link.rb,
lib/ducktape/bindable.rb,
lib/ducktape/hookable.rb,
lib/ducktape/converter.rb,
lib/ducktape/binding_source.rb,
lib/ducktape/ext/def_hookable.rb,
lib/ducktape/bindable_attribute.rb,
lib/ducktape/expression/indexer_exp.rb,
lib/ducktape/expression/literal_exp.rb,
lib/ducktape/expression/property_exp.rb,
lib/ducktape/expression/binary_op_exp.rb,
lib/ducktape/expression/qualified_exp.rb,
lib/ducktape/expression/binding_parser.rb,
lib/ducktape/expression/identifier_exp.rb,
lib/ducktape/validators/proc_validator.rb,
lib/ducktape/validators/class_validator.rb,
lib/ducktape/validators/range_validator.rb,
lib/ducktape/bindable_attribute_metadata.rb,
lib/ducktape/validators/regexp_validator.rb,
lib/ducktape/validators/equality_validator.rb

Overview

Although against sematinc versioning recommendation, while version is < 1.0.0, an increase in the minor version number may represent an incompatible implementation with the previous minor version, which should have been represented by a major version number increase.

Defined Under Namespace

Modules: Bindable, Expression, Hookable Classes: AttributeNotDefinedError, BindableAttribute, BindableAttributeMetadata, BindingSource, ClassValidator, Converter, EqualityValidator, InconsistentAccessorError, InvalidAttributeValueError, Link, ProcValidator, RangeValidator, RegexpValidator

Constant Summary collapse

VERSION =
'0.5.0'.freeze

Class Method Summary collapse

Class Method Details

.def_hookable(klass, *args) ⇒ Object



5
6
7
8
9
10
11
12
13
# File 'lib/ducktape/ext/def_hookable.rb', line 5

def self.def_hookable(klass, *args)
  return if args.length == 0
  names_hash = args.extract_options!

  # reversed merge because names_hash has priority
  @hookable_types[klass] = Hash[args.flatten.map { |v| [v, v] }].merge!(names_hash)

  nil
end

.hookable(obj) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/ducktape/ext/def_hookable.rb', line 15

def self.hookable(obj)
  return obj if obj.is_a?(Hookable)
  m = obj.class.ancestors.find { |c| @hookable_types.has_key?(c) }
  return obj unless m
  obj.singleton_class.send :include, Hookable
  obj.singleton_class.make_hooks(@hookable_types[m])
  obj
end