Module: Representable
- Included in:
- Decorator
- Defined in:
- lib/representable/pipeline_factories.rb,
lib/representable.rb,
lib/representable/xml.rb,
lib/representable/hash.rb,
lib/representable/json.rb,
lib/representable/yaml.rb,
lib/representable/debug.rb,
lib/representable/cached.rb,
lib/representable/config.rb,
lib/representable/insert.rb,
lib/representable/object.rb,
lib/representable/option.rb,
lib/representable/binding.rb,
lib/representable/version.rb,
lib/representable/coercion.rb,
lib/representable/pipeline.rb,
lib/representable/decorator.rb,
lib/representable/populator.rb,
lib/representable/definition.rb,
lib/representable/serializer.rb,
lib/representable/declarative.rb,
lib/representable/xml/binding.rb,
lib/representable/deserializer.rb,
lib/representable/hash/binding.rb,
lib/representable/hash_methods.rb,
lib/representable/yaml/binding.rb,
lib/representable/for_collection.rb,
lib/representable/object/binding.rb,
lib/representable/hash/allow_symbols.rb
Overview
NOTE: this might become a separate class, that’s why it’s in a separate file.
Defined Under Namespace
Modules: Cached, ClassMethods, Coercion, CreateObject, Debug, Declarative, ForCollection, Function, Hash, HashMethods, JSON, ModuleExtensions, Object, Represent, XML, YAML Classes: Binding, Collect, Config, Decorator, Definition, DeserializeError, Option, Pipeline, Populator
Constant Summary collapse
- VERSION =
"3.2.0"
- FindOrInstantiate =
Populator::FindOrInstantiate
- Getter =
->(input, ) do [:binding].evaluate_option(:getter, input, ) end
- GetValue =
->(_input, ) { [:binding].send(:exec_context, ).public_send([:binding].getter) }
- Writer =
->(input, ) do [:binding].evaluate_option(:writer, input, ) Pipeline::Stop end
- RenderDefault =
TODO: evaluate this, if we need this.
->(input, ) do binding = [:binding] binding.skipable_empty_value?(input) ? binding[:default] : input end
- StopOnSkipable =
->(input, ) do [:binding].send(:skipable_empty_value?, input) ? Pipeline::Stop : input end
- RenderFilter =
->(input, ) do [:binding][:render_filter].(input, ) end
- SkipRender =
->(input, ) do [:binding].evaluate_option(:skip_render, input, ) ? Pipeline::Stop : input end
- Serializer =
->(input, ) do return if input.nil? # DISCUSS: how can we prevent that? [:binding].evaluate_option(:serialize, input, ) end
- Serialize =
->(input, ) do return if input.nil? # DISCUSS: how can we prevent that? binding, = [:binding], [:options] # FIXME: rename to :local_options. = OptionsForNested.(, binding) input.send(binding.serialize_method, ) end
- WriteFragment =
->(input, ) { [:binding].write([:doc], input, [:as]) }
- As =
->(input, ) { [:binding].evaluate_option(:as, input, ) }
- AssignAs =
Warning: don’t rely on AssignAs/AssignName, i am not sure if i leave that as functions.
->(input, ) { [:as] = As.(input, ); input }
- AssignName =
->(input, ) { [:as] = [:binding].name; input }
- AssignFragment =
Deprecation strategy: binding.evaluate_option_with_deprecation(:reader, options, :doc)
=> binding.evaluate_option(:reader, options) # always pass in options.
->(input, ) { [:fragment] = input }
- ReadFragment =
->(input, ) { [:binding].read(input, [:as]) }
- Reader =
->(input, ) { [:binding].evaluate_option(:reader, input, ) }
- StopOnNotFound =
->(input, ) do Binding::FragmentNotFound == input ? Pipeline::Stop : input end
- StopOnNil =
DISCUSS: Not tested/used, yet.
->(input, ) do # DISCUSS: Not tested/used, yet. input.nil? ? Pipeline::Stop : input end
- OverwriteOnNil =
->(input, ) do input.nil? ? (SetValue.(input, ); Pipeline::Stop) : input end
- Default =
->(input, ) do Binding::FragmentNotFound == input ? [:binding][:default] : input end
- SkipParse =
->(input, ) do [:binding].evaluate_option(:skip_parse, input, ) ? Pipeline::Stop : input end
- Prepare =
CreateObject = Function::CreateObject.new
Function::Prepare.new
- Decorate =
Function::Decorate.new
- Deserializer =
->(input, ) { [:binding].evaluate_option(:deserialize, input, ) }
- Deserialize =
->(input, args) do binding, fragment, = args[:binding], args[:fragment], args[:options] # user_options: = OptionsForNested.(, args[:binding]) input.send(binding.deserialize_method, fragment, ) end
- ParseFilter =
->(input, ) do [:binding][:parse_filter].(input, ) end
- Setter =
->(input, ) { [:binding].evaluate_option(:setter, input, ) }
- SetValue =
->(input, ) { [:binding].send(:exec_context, ).send([:binding].setter, input) }
- Stop =
->(*) { Pipeline::Stop }
- If =
->(input, ) { [:binding].evaluate_option(:if, nil, ) ? input : Pipeline::Stop }
- StopOnExcluded =
->(input, ) do return input unless [:options] return input unless props = ([:options][:exclude] || [:options][:include]) res = props.include?([:binding].name.to_sym) # false with include: Stop. false with exclude: go! return input if [:options][:include]&&res return input if [:options][:exclude]&&!res Pipeline::Stop end
Instance Attribute Summary collapse
-
#representable_attrs ⇒ Object
writeonly
Sets the attribute representable_attrs.
Class Method Summary collapse
Instance Attribute Details
#representable_attrs=(value) ⇒ Object
Sets the attribute representable_attrs
30 31 32 |
# File 'lib/representable.rb', line 30 def representable_attrs=(value) @representable_attrs = value end |
Class Method Details
.included(base) ⇒ Object
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/representable.rb', line 32 def self.included(base) base.class_eval do extend Declarative # make Representable horizontally and vertically inheritable. extend ModuleExtensions, ::Declarative::Heritage::Inherited, ::Declarative::Heritage::Included extend ClassMethods extend ForCollection extend Represent end end |
.Option(value) ⇒ Object
16 17 18 |
# File 'lib/representable/option.rb', line 16 def self.Option(value) ::Representable::Option.build(value) end |