Sha256: c0593b2efba1accf7fb0ad4886345c3d88d254da51e2511d4f7fcc7393780bd1

Contents?: true

Size: 854 Bytes

Versions: 2

Compression:

Stored size: 854 Bytes

Contents

require 'caruby/resource'

module CaRuby
  # The Annotation module marks a domain object as an Annotation.
  module Annotation
    include Resource

    # Dynamically creates a new annotable owner attribute with the given symbol if symbol is an annotatable owner attribute
    # accessor method.
    #
    # @see #attribute_missing
    def method_missing(symbol, *args)
      name = symbol.to_s
      # remove trailing assignment = if present
      name.chop! if name =~ /=$/
      # try to make the owner attribute
      self.class.attribute_metadata(name.to_sym)
      # if we reached here, then the owner was created so verify and call the new method
      raise NoMethodError.new("#{name.demodulize} owner attribute #{name} created but accessor method not found: #{symbol}") unless method_defined?(symbol)
      send(symbol, *args)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
caruby-core-1.4.2 lib/caruby/domain/annotation.rb
caruby-core-1.4.1 lib/caruby/domain/annotation.rb