Class: Faalis::Dashboard::FormFieldsProperties

Inherits:
Object
  • Object
show all
Defined in:
lib/faalis/dashboard/dsl/form_fields_properties.rb

Instance Method Summary (collapse)

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

- (Object) method_missing(m, *args, &block)



45
46
47
48
49
50
51
52
53
54
# File 'lib/faalis/dashboard/dsl/form_fields_properties.rb', line 45

def method_missing(m, *args, &block)
  @fields ||= {}
  if self.respond_to? m
    return self.send(m, *args, &block)
  else
    # FIXME: This probably is a bad idea. We should get the whole
    # args
    @fields[m] = args[0]
  end
end

Instance Method Details

- (Object) [](index)



38
39
40
41
42
43
# File 'lib/faalis/dashboard/dsl/form_fields_properties.rb', line 38

def [](index)
  unless @fields.nil?
    return @fields[index] || {}
  end
  {}
end

- (Object) []=(name, detail)



33
34
35
36
# File 'lib/faalis/dashboard/dsl/form_fields_properties.rb', line 33

def []=(name, detail)
  @fields ||= {}
  @fields[name.to_sym] = detail
end

- (Object) fields



29
30
31
# File 'lib/faalis/dashboard/dsl/form_fields_properties.rb', line 29

def fields
  @fields || {}
end

- (Object) fields=(all_fields)



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/faalis/dashboard/dsl/form_fields_properties.rb', line 8

def fields=(all_fields)
  fields.each do |name, field|
    unless all_fields.include? name.to_s
      raise ArgumentError, "'#{name}' is not a valid field"
    end
  end

  all_fields.each do |name, field|
    unless fields.include?(name.to_sym)

      Rails.logger.debug("FIELD NAME: #{name}")
      Rails.logger.debug("FIELD TYPE: #{field.type}")

      if self.respond_to?("setup_#{field.type}".to_sym, true)
        puts "sdasda" * 100
        send("setup_#{field.type}", name)
      end
    end
  end
end

- (Object) initializer



4
5
6
# File 'lib/faalis/dashboard/dsl/form_fields_properties.rb', line 4

def initializer
  @fields = {}
end

- (Object) to_hash



56
57
58
# File 'lib/faalis/dashboard/dsl/form_fields_properties.rb', line 56

def to_hash
  fields
end