Sha256: fb92e3e856aed92d114505b66e28f3d3f69830b896cb2ba4dd5f93c4d73d3bca

Contents?: true

Size: 853 Bytes

Versions: 15

Compression:

Stored size: 853 Bytes

Contents

module GEPUB
  module BuilderMixin
    def method_missing(name, *args)
      if Array === @last_defined_item &&
          @last_defined_item.size > 0 &&
          @last_defined_item[0].respond_to?(name.to_sym)

        if !(@last_defined_item[0].apply_one_to_multi ||
             @last_defined_item.size != 1) &&
            @last_defined_item.size != args.size
          warn "appling #{args} to #{@last_defined_item}: length differs."
        end

        @last_defined_item.each_with_index {
          |item, i|
          if item.apply_one_to_multi && args.size == 1
            item.send(name, args[0])
          elsif !args[i].nil?
            item.send(name, args[i])
          end
        }
      elsif @last_defined_item.respond_to?(name.to_sym)
        @last_defined_item.send(name, *args)
      else
        super
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
gepub-0.6.8.5 lib/gepub/builder_mixin.rb
gepub-0.6.8.3 lib/gepub/builder_mixin.rb
gepub-0.6.8 lib/gepub/builder_mixin.rb
gepub-0.6.6 lib/gepub/builder_mixin.rb
gepub-0.6.5.2 lib/gepub/builder_mixin.rb
gepub-0.6.5.1 lib/gepub/builder_mixin.rb
gepub-0.6.4.6 lib/gepub/builder_mixin.rb
gepub-0.6.4.5 lib/gepub/builder_mixin.rb
gepub-0.6.4.4 lib/gepub/builder_mixin.rb
gepub-0.6.4.3 lib/gepub/builder_mixin.rb
gepub-0.6.4.2 lib/gepub/builder_mixin.rb
gepub-0.6.4.1 lib/gepub/builder_mixin.rb
gepub-0.6.4 lib/gepub/builder_mixin.rb
gepub-0.6.3.1 lib/gepub/builder_mixin.rb
gepub-0.6.3 lib/gepub/builder_mixin.rb