Sha256: 150a826963be2bfd53199741d551f82597f2507655c0c811b6242b25779c13e4

Contents?: true

Size: 774 Bytes

Versions: 6

Compression:

Stored size: 774 Bytes

Contents

module Crudboy
  class TemplateContext

    include Helper

    attr_accessor :model, :columns, :table_name, :model_name, :bundle_options

    def initialize(definition)
      @model = definition.model
      @model_name = definition.model_name
      @table_name = definition.table_name
      @columns = @model.columns
    end

    def eval(string)
      instance_eval(format('%%Q{%s}', string), string, 0)
    end

    def binding
      Kernel::binding
    end

    def columns(**options)
      model.columns(**options)
    end

    def method_missing(method, *args, **options, &block)
      if args.empty? && options.empty? && block.nil? && bundle_options.table.keys.include?(method)
        bundle_options.send(method)
      else
        super
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
crudboy-0.1.5 lib/crudboy/template_context.rb
crudboy-0.1.4 lib/crudboy/template_context.rb
crudboy-0.1.3 lib/crudboy/template_context.rb
crudboy-0.1.2 lib/crudboy/template_context.rb
crudboy-0.1.1 lib/crudboy/template_context.rb
crudboy-0.1.0 lib/crudboy/template_context.rb