Class: LinkedRails::Collection::FilterField

Inherits:
RDF::Node
  • Object
show all
Includes:
ActiveModel::Model, ActiveModel::Serialization, LinkedRails::CallableVariable, Model
Defined in:
app/models/linked_rails/collection/filter_field.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Model

#build_child, #singular_resource?

Methods included from Model::Serialization

#preview_includes, #show_includes

Methods included from Model::Iri

#anonymous_iri, #anonymous_iri?, #iri_opts, #rdf_type, #reload, #root_relative_iri, #route_fragment

Methods included from Model::Enhancements

#enhanced_with?

Methods included from Model::Dirty

#previous_changes_by_predicate, #previously_changed_relations

Methods included from Model::Collections

#collection_for, #parent_collections

Instance Attribute Details

#collectionObject

Returns the value of attribute collection.



11
12
13
# File 'app/models/linked_rails/collection/filter_field.rb', line 11

def collection
  @collection
end

#keyObject

Returns the value of attribute key.



11
12
13
# File 'app/models/linked_rails/collection/filter_field.rb', line 11

def key
  @key
end

#klassObject

Returns the value of attribute klass.



11
12
13
# File 'app/models/linked_rails/collection/filter_field.rb', line 11

def klass
  @klass
end

#options_array=(value) ⇒ Object (writeonly)

Sets the attribute options_array

Parameters:

  • value

    the value to set the attribute options_array to.



12
13
14
# File 'app/models/linked_rails/collection/filter_field.rb', line 12

def options_array=(value)
  @options_array = value
end

#options_in=(value) ⇒ Object (writeonly)

Sets the attribute options_in

Parameters:

  • value

    the value to set the attribute options_in to.



12
13
14
# File 'app/models/linked_rails/collection/filter_field.rb', line 12

def options_in=(value)
  @options_in = value
end

Instance Method Details

#filter_option(option) ⇒ Object



24
25
26
27
# File 'app/models/linked_rails/collection/filter_field.rb', line 24

def filter_option(option)
  attrs = option.is_a?(Hash) ? option : {value: option}
  Collection::FilterOption.new(attrs.merge(collection: collection, key: key))
end

#iri(_opts = {}) ⇒ Object



16
17
18
# File 'app/models/linked_rails/collection/filter_field.rb', line 16

def iri(_opts = {})
  self
end

#optionsObject



20
21
22
# File 'app/models/linked_rails/collection/filter_field.rb', line 20

def options
  @options ||= options_array&.map(&method(:filter_option)) || []
end