lib/compositor/dsl.rb in compositor-0.1.1 vs lib/compositor/dsl.rb in compositor-0.1.3
- old
+ new
@@ -1,27 +1,24 @@
module Compositor
class DSL
- attr_reader :view_context
- attr_accessor :result, :generator
+ attr_reader :context
+ attr_accessor :generator
- def initialize(view_context)
- @view_context = view_context
+ def initialize(context)
+ @context = context
end
- def self.create(view_context, &block)
- dsl = new(view_context)
+ def self.create(context, &block)
+ dsl = new(context)
+ context.instance_variables.each do |variable|
+ dsl.instance_variable_set(variable, context.instance_variable_get(variable))
+ end
dsl.instance_eval &block if block
dsl
end
- def paginate collection, params
- paginator collection: collection,
- pagination_url: params[:pagination_url],
- params: params[:api_params]
- end
-
- def to_json
- generator.to_json
+ def to_json(options = {})
+ generator.to_json(options)
end
def to_hash
if generator
generator.to_hash