Module: ForestLiana::SchemaHelper

Defined in:
app/helpers/forest_liana/schema_helper.rb

Class Method Summary collapse

Class Method Details

.find_collection_from_model(active_record_class) ⇒ Object



3
4
5
6
# File 'app/helpers/forest_liana/schema_helper.rb', line 3

def self.find_collection_from_model(active_record_class)
  collection_name = ForestLiana.name_for(active_record_class)
  ForestLiana.apimap.find { |collection| collection.name.to_s == collection_name }
end

.is_smart_field?(model, field_name) ⇒ Boolean

Returns:

  • (Boolean)


8
9
10
11
12
# File 'app/helpers/forest_liana/schema_helper.rb', line 8

def self.is_smart_field?(model, field_name)
  collection = self.find_collection_from_model(model)
  field_found = collection.fields.find { |collection_field| collection_field[:field].to_s == field_name } if collection
  field_found && field_found[:is_virtual]
end