Module: Hyrax::Flexibility

Extended by:
ActiveSupport::Concern
Defined in:
app/models/concerns/hyrax/flexibility.rb

Instance Method Summary collapse

Instance Method Details

#contexts=(value) ⇒ Object



86
87
88
89
# File 'app/models/concerns/hyrax/flexibility.rb', line 86

def contexts=(value)
  val = Array.wrap(value).map { |v| v.split }.flatten
  @attributes[:contexts] = val
end

#flexible?Boolean

Returns:

  • (Boolean)


96
97
98
# File 'app/models/concerns/hyrax/flexibility.rb', line 96

def flexible?
  self.class.flexible?
end

#inspectObject

Override inspect from dry-struct 1.6.0 to enable dynamic schema loading



101
102
103
104
105
# File 'app/models/concerns/hyrax/flexibility.rb', line 101

def inspect
  klass = self.singleton_class
  attrs = klass.attribute_names.map { |key| " #{key}=#{@attributes[key].inspect}" }.join
  "#<#{klass.name || klass.inspect}#{attrs}>"
end

#set_value(key, value) ⇒ Object

Override set_value from valkyrie 3.1.1 to enable dynamic schema loading



92
93
94
# File 'app/models/concerns/hyrax/flexibility.rb', line 92

def set_value(key, value)
  @attributes[key.to_sym] = self.singleton_class.schema.key(key.to_sym).type.call(value)
end