module Apia::Defineable
Public Instance Methods
create(id, &block)
click to toggle source
Create a new object
@param id [String] @return [Class]
# File lib/apia/defineable.rb, line 18 def create(id, &block) klass = Class.new(self) klass.definition.id = id if block_given? klass.definition.dsl.instance_eval(&block) end klass end
inspect()
click to toggle source
Inspect an object
@return [String]
# File lib/apia/defineable.rb, line 9 def inspect type = ancestors.find { |c| c.name =~ /\AApia::/ } "<#{definition.id} [#{type}]>" end
method_missing(name, *args, **kwargs, &block)
click to toggle source
Passes all other values through to the DSL
for the definition if the DSL
supoprts it.
Calls superclass method
# File lib/apia/defineable.rb, line 43 def method_missing(name, *args, **kwargs, &block) if definition.dsl.respond_to?(name) if kwargs.empty? definition.dsl.send(name, *args, &block) else definition.dsl.send(name, *args, **kwargs, &block) end else super end end
name(new_name = nil)
click to toggle source
Ability to set a name (for DSL
purposes) but also returns a name of the actual class if no new value is provided
@param new_name [String, nil] @return [String]
Calls superclass method
# File lib/apia/defineable.rb, line 32 def name(new_name = nil) if new_name definition.name = new_name return new_name end super() end
respond_to_missing?(name, include_private = false)
click to toggle source
Calls superclass method
# File lib/apia/defineable.rb, line 55 def respond_to_missing?(name, include_private = false) definition.dsl.respond_to?(name) || super end