Module: Ducktape

Defined in:
lib/ducktape/version.rb,
lib/ducktape/link.rb,
lib/ext/def_hookable.rb,
lib/ducktape/bindable.rb,
lib/ducktape/hookable.rb,
lib/ducktape/converter.rb,
lib/ducktape/binding_source.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/bindable_attribute_metadata.rb

Overview

Although against rubygems 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, Converter, InconsistentAccessorError, InvalidAttributeValueError, Link

Constant Summary collapse

VERSION =
'0.4.0'.freeze

Class Method Summary collapse

Class Method Details

.def_hookable(klass, *args) ⇒ Object



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

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

  names_hash = args.pop if args.last.is_a?(Hash)
  names_hash ||= {}

  #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



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

def self.hookable(obj)
  return obj if obj.is_a?(Hookable)
  m = obj.class.ancestors.each { |c| v = @hookable_types[c]; break v if v }
  return obj unless m
  (class << obj; include Hookable; self end).make_hooks(m)
  obj
end