Class: Cloudsearchable::DSL

Inherits:
Object
  • Object
show all
Defined in:
lib/cloudsearchable.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(domain, base) ⇒ DSL

Returns a new instance of DSL.



63
64
65
66
# File 'lib/cloudsearchable.rb', line 63

def initialize domain, base
  @domain = domain
  @base = base
end

Instance Attribute Details

#baseObject (readonly)

Returns the value of attribute base.



61
62
63
# File 'lib/cloudsearchable.rb', line 61

def base
  @base
end

#domainObject (readonly)

Returns the value of attribute domain.



61
62
63
# File 'lib/cloudsearchable.rb', line 61

def domain
  @domain
end

Instance Method Details

#field(name, type, options = {}, &block) ⇒ Object



80
81
82
83
84
85
86
# File 'lib/cloudsearchable.rb', line 80

def field name, type, options = {}, &block
  # This block is executed in the context of the record
  if block_given?
    options[:source] = block.to_proc
  end
  domain.add_field name, type, options
end

#literal(name, options = {}, &block) ⇒ Object



76
77
78
# File 'lib/cloudsearchable.rb', line 76

def literal name, options = {}, &block
  field name, :literal, options, &block
end

#text(name, options = {}, &block) ⇒ Object



72
73
74
# File 'lib/cloudsearchable.rb', line 72

def text name, options = {}, &block
  field name, :text, options, &block
end

#uint(name, options = {}, &block) ⇒ Object



68
69
70
# File 'lib/cloudsearchable.rb', line 68

def uint name, options = {}, &block
  field name, :uint, options, &block
end