Sha256: 6358a27faeae24928dd937f812b52bddd9dd7bbf9b66953c7f6088a9474795e9
Contents?: true
Size: 985 Bytes
Versions: 6
Compression:
Stored size: 985 Bytes
Contents
module Dao class Api class DSL < BlankSlate attr_accessor :api def initialize(api) @api = api #@evaluate = Object.instance_method(:instance_eval).bind(self) end def evaluate(&block) #@evaluate.call(&block) @api.module_eval(&block) ensure #no_docs_left_on_stack! end def no_docs_left_on_stack! raise "no interface for #{ docs.inspect }" unless docs.empty? end %w( interface call doc docs description desc ).each do |method| module_eval <<-__, __FILE__, __LINE__ - 1 def #{ method }(*args, &block) api.#{ method }(*args, &block) end __ end end class << Api def evaluate(&block) @dsl ||= DSL.new(api=self) @dsl.evaluate(&block) end end end def Dao.api(&block) if block api = Class.new(Api) api.evaluate(&block) api else Api end end end
Version data entries
6 entries across 6 versions & 1 rubygems
Version | Path |
---|---|
dao-4.2.1 | lib/dao/api/dsl.rb |
dao-3.3.0 | lib/dao/api/dsl.rb |
dao-3.2.0 | lib/dao/api/dsl.rb |
dao-3.1.2 | lib/dao/api/dsl.rb |
dao-3.1.1 | lib/dao/api/dsl.rb |
dao-3.1.0 | lib/dao/api/dsl.rb |