Class: Syphon::Schema::DSL

Inherits:
Struct
  • Object
show all
Defined in:
lib/syphon/schema.rb

Instance Method Summary collapse

Instance Method Details

#_eval(&block) ⇒ Object



126
127
128
129
130
131
132
133
# File 'lib/syphon/schema.rb', line 126

def _eval(&block)
  if block.arity == 1
    block.call(self)
  else
    instance_eval(&block)
  end
  schema
end

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



135
136
137
# File 'lib/syphon/schema.rb', line 135

def field(name, type, expression, options = {})
  schema.fields[name.to_sym] = Field.new(schema, name, type, expression, options)
end

#join(string = nil, &block) ⇒ Object



166
167
168
169
170
# File 'lib/syphon/schema.rb', line 166

def join(string = nil, &block)
  string && block and
    raise ArgumentError, "both string and block given"
  schema.joins << (string || block)
end

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



147
148
149
# File 'lib/syphon/schema.rb', line 147

def nested(name, options = {}, &block)
  schema.fields[name.to_sym] = NestedField.new(schema, name, options, &block)
end