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



94
95
96
# File 'lib/modalfields/modalfields.rb', line 94

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)



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

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

#field_migration(type, &blk) ⇒ Object



85
86
87
88
89
# File 'lib/modalfields/modalfields.rb', line 85

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



80
81
82
83
84
# File 'lib/modalfields/modalfields.rb', line 80

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