Class: ModalFields::HooksDsl

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

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &blk) ⇒ Object



92
93
94
# File 'lib/modalfields/modalfields.rb', line 92

def method_missing(name, *args, &blk)
  field_type name, *args, &blk
end

Instance Method Details

#all_fields(&blk) ⇒ Object

generic filter applied to all the fields (after a specific filter for the type, if there is one)



89
90
91
# File 'lib/modalfields/modalfields.rb', line 89

def all_fields(&blk)
  field_type :all_fields, &blk
end

#field_migration(type, &blk) ⇒ Object



83
84
85
86
87
# File 'lib/modalfields/modalfields.rb', line 83

def field_migration(type, &blk)
  ModalFields.migration_hooks[type.to_sym] = lambda{|model, column_declaration|
    blk[model, column_declaration]
  }
end

#field_type(type, &blk) ⇒ Object



78
79
80
81
82
# File 'lib/modalfields/modalfields.rb', line 78

def field_type(type, &blk)
  ModalFields.hooks[type.to_sym] = lambda{|model, column_declaration|
    blk[model, column_declaration]
  }
end