Class: Ansr::Arel::ConfiguredField

Inherits:
Arel::Attributes::Attribute
  • Object
show all
Defined in:
lib/ansr/arel/configured_field.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(relation, name, config = {}) ⇒ ConfiguredField

Returns a new instance of ConfiguredField.



4
5
6
7
# File 'lib/ansr/arel/configured_field.rb', line 4

def initialize(relation, name, config={})
	super(relation, name)
	@config = {local: {}, query: {}}.merge(config)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args) ⇒ Object



14
15
16
17
# File 'lib/ansr/arel/configured_field.rb', line 14

def method_missing(method, *args)
  @config[method] = args if args.first
  @config[method]
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



3
4
5
# File 'lib/ansr/arel/configured_field.rb', line 3

def config
  @config
end

Instance Method Details

#localObject



11
12
13
# File 'lib/ansr/arel/configured_field.rb', line 11

def local
  @config[:local]
end

#queryObject



8
9
10
# File 'lib/ansr/arel/configured_field.rb', line 8

def query
  @config[:query]
end