Module: ActiveScaffold::SemanticAttributesBridge

Defined in:
lib/active_scaffold/bridges/semantic_attributes/lib/semantic_attributes_bridge.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



3
4
5
# File 'lib/active_scaffold/bridges/semantic_attributes/lib/semantic_attributes_bridge.rb', line 3

def self.included(base)
  base.class_eval { alias_method_chain :initialize, :semantic_attributes }
end

Instance Method Details

#initialize_with_semantic_attributes(name, active_record_class) ⇒ Object



7
8
9
10
11
12
13
14
15
# File 'lib/active_scaffold/bridges/semantic_attributes/lib/semantic_attributes_bridge.rb', line 7

def initialize_with_semantic_attributes(name, active_record_class)
  initialize_without_semantic_attributes(name, active_record_class)
  self.required = !active_record_class.semantic_attributes[self.name].predicates.find {|p| p.allow_empty? == false }.nil?
  active_record_class.semantic_attributes[self.name].predicates.find do |p|
    sem_type = p.class.to_s.split('::')[1].underscore.to_sym
    next if [:required, :association].include?(sem_type)
    @form_ui = sem_type
  end
end