Module: Ladder::Resource::Dynamic
- Extended by:
- ActiveSupport::Concern
- Includes:
- Ladder::Resource
- Defined in:
- lib/ladder/resource/dynamic.rb
Defined Under Namespace
Modules: InstanceMethods
Instance Method Summary collapse
-
#property(field_name, opts = {}) ⇒ Hash
Dynamically define a field on the object instance; in addition to (or overloading) class-level properties.
Methods included from Ladder::Resource
#<<, from_uri, #klass_from_predicate, #update_resource
Methods included from Serializable
#as_framed_jsonld, #as_jsonld, #as_qname
Instance Method Details
#property(field_name, opts = {}) ⇒ Hash
Dynamically define a field on the object instance; in addition to (or overloading) class-level properties
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/ladder/resource/dynamic.rb', line 28 def property(field_name, opts = {}) # Store context information self._context ||= Hash.new(nil) # Ensure new field name is unique field_name = opts[:predicate].qname.join('_').to_sym if resource_class.properties.symbolize_keys.keys.include? field_name self._context[field_name] = opts[:predicate].to_s apply_context end |