Class: ParsleySimpleForm::Constraints::BaseConstraint

Inherits:
Object
  • Object
show all
Defined in:
lib/parsley_simple_form/constraints/base_constraint.rb

Instance Method Summary collapse

Constructor Details

#initialize(form_builder, options, &block) ⇒ BaseConstraint

Returns a new instance of BaseConstraint.



5
6
7
8
9
# File 'lib/parsley_simple_form/constraints/base_constraint.rb', line 5

def initialize(form_builder,options,&block)
  @form_builder = form_builder
  @options = options
  @block = block
end

Instance Method Details

#input_id(attribute_name, options, &block) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/parsley_simple_form/constraints/base_constraint.rb', line 16

def input_id(attribute_name, options, &block)
  input = @form_builder.find_input(attribute_name, options, &block)
  if input.lookup_model_names.count > 1
    (input.lookup_model_names * '_') + '_attributes_' + input.attribute_name.to_s
  else
    (input.lookup_model_names * '_') + '_' + input.attribute_name.to_s
  end        
end

#input_type(attribute_name, options, &block) ⇒ Object



11
12
13
14
# File 'lib/parsley_simple_form/constraints/base_constraint.rb', line 11

def input_type(attribute_name, options, &block)
  input = @form_builder.find_input(attribute_name, options, &block)
  input.input_type or :string
end