Sha256: a3041285bf651fd7551eebe476b9f20d91d584bf4ee6b05343356876ff6a3c7d

Contents?: true

Size: 850 Bytes

Versions: 4

Compression:

Stored size: 850 Bytes

Contents

module Legato
  module Model
    def self.extended(base)
      ProfileMethods.add_profile_method(base)
    end

    def metrics(*fields)
      @metrics ||= ListParameter.new(:metrics)
      @metrics << fields
    end

    def dimensions(*fields)
      @dimensions ||= ListParameter.new(:dimensions)
      @dimensions << fields
    end

    def filters
      @filters ||= {}
    end

    def filter(name, &block)
      filters[name] = block

      (class << self; self; end).instance_eval do
        define_method(name) {|*args| Query.new(self).apply_filter(*args, &block)}
      end
    end

    # def set_instance_klass(klass)
    #   @instance_klass = klass
    # end

    # def instance_klass
    #   @instance_klass || OpenStruct
    # end

    def results(profile, options = {})
      Query.new(self).results(profile, options)
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
legato-0.0.6 lib/legato/model.rb
legato-0.0.5 lib/legato/model.rb
legato-0.0.4 lib/legato/model.rb
legato-0.0.2 lib/legato/model.rb