Sha256: d01198895012c5b10ef197e8816c035944ea7572379f0d5d7cef6dc9b0fe8625

Contents?: true

Size: 427 Bytes

Versions: 1

Compression:

Stored size: 427 Bytes

Contents

class Respondie::Builder
  
  def initialize(pattern, controller)
    @pattern = pattern
    custom = Class.new(ActionController::Responder)
    controller.responder = custom
    @responder = controller.responder
  end
  
  def method_missing(sym)
    trait sym
  end
  
  private
  
  def trait(sym)
    type = @pattern.gsub(/\$trait\$/, sym.to_s.camelize)
    @responder.send :include, type.constantize
    self
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
respondie-0.9.0 lib/respondie/builder.rb